Questions tagged [perl]

Perl is a high-level, general-purpose, interpreted, dynamic programming language. It was originally developed by Larry Wall as a general-purpose Unix scripting language to make report processing easier, over a period with support from open source community, it has evolved and matured to be used for graphics programming, system administration, network programming, finance, bioinformatics, and other engineering applications.

Filter by
Sorted by
Tagged with
0
votes
1answer
44 views

how to add words before line on all the scripts in current folder

under /home/scrript , we have 187 bash scripts all the scripts have the following line: kill -PIPE $PID we want to add the following words before this line on all the scripts as the following [[ $...
0
votes
1answer
260 views

Get lines of file matching a regex

Is there a more compact way to get lines of a file that match a regex than the following? open my $fh, '<', $file or die "Cannot open $file: $!"; while ( my $line = <$fh> ) { next ...
0
votes
2answers
2k views

Check which process is using most memory and summary total used memory

by the following command we can check which process is using most memory as we can see the first field show in MB the used for each process is it possible by awk to sum all the numbers and to get ...
0
votes
1answer
61 views

Insert new text in the middle of a file replacing old text without re-inserting the same things over and over?

I have a file that I want to update relatively frequently. What needs to be done is that a specific part of the file would be changed to include some more lines. I am doing it with sed and \a option: ...
14
votes
5answers
9k views

Remove duplicate lines while keeping the order of the lines

[root@server]# awk '!seen[$0]++' out.txt > cleaned awk: (FILENAME=out.txt FNR=8547098) fatal error: internal error Aborted [root@server]# The ""server"" has: 8 GByte RAM + 16 GByte SWAP, x>300 ...
-2
votes
2answers
54 views

Data Manipulation

I have a data as mentioned below. host_name Server1.domain.com contacts DL - Desktop contact_groups ravi, raj, rahim host_name Server2.domain.com contact_groups DL-Server host_name Server3....
-2
votes
3answers
160 views

Deleting Lines, which match a particular Identifier from another file

I have 2 files. File 1, has an identifier (eg. D7MHBF:11:1449:1988) and every new entry starts with @. It has few more fields, which are not important in our analysis. File 2 consists of a column of ...
1
vote
2answers
106 views

Execute Perl commands from a specific IP?

I have a Debian Jessie 8 server with three unique IPv4 IPs. I connect to the server from Windows 7 via Putty. I can open three Putty windows using each of the three IPs. I am trying to execute a Perl ...
2
votes
2answers
1k views

Format the content of the file using Perl

I have a file with the following format: >Country1 Aus trali a >Country5 Swi tzer land >Country2 Net herland s I want to output a file with the following format: >Country1 Australia &...
0
votes
1answer
453 views

Splitting a file using perl

I have a csv file and like to split the file into smaller files based on column matching in the file using perl. I am working on Linux Rhel6. example: fruit1, fruit2,pricerate,quantity orange, ...
1
vote
3answers
61 views

Swap lat lon and group by square brackets

I have A file which is having data like input.csv 1;1.30453 103.83589;1.306663 103.83587;1.30 103.5;1.30693 103.83883;1.30709 103.835793;1.30725 103.835757;1.30741 103.83572;1.30753 103.8798 2;1.353 ...
1
vote
4answers
2k views

Pattern Matching and Delete the whole line

I want to delete all the Lines of File 1, if Column1 of File1 matches exactly with Column 1 File2. File 1: r001:21:10 21 AAAAAATTTGC * = XM:21 r002:21:10 21 YAAAATTTGC * ...
1
vote
1answer
386 views

Error when compiling XML-Parser-2.44 with Perl

When trying to perl Makefile.pl XML-Parser-2.44 while chrooted in LFS, I get this error: Checking if your kit is complete... Looks good Warning: prerequisite LWP::UserAgent 0 not found. Have /tools/...
-1
votes
2answers
566 views

How to remove line break if line character count less than n chars [closed]

I need to concatenate the line with next line if the line char count is less than x chars.
0
votes
1answer
1k views

How to instal Perl modules GD and GD::Polyline in Debian?

I am trying to start Circos in Debian but I get two missing modules root@masi:/home/masi/circos-0.69# bin/circos -modules | grep missing missing GD missing GD::Polyline Trying ...
0
votes
1answer
61 views

rearranging from colum to row in a csv [duplicate]

I have a CSV file that presently has an output like this 1 2 3 4 5 what I need to do is reconfigure the output as follows 1 2 3 4 5 all the entry data on one line.
4
votes
4answers
119 views

Replace pattern each time with a different string (taken from external file)

I have an input: a b TOCHANGE c d e TOCHANGE where I need to change the patterns "TOCHANGE" using an external file : line1 line2 ... so that I get the following output : a b line1 c d e ...
2
votes
2answers
132 views

Sed/awk/perl: modify text preserving parts and align to a column

I have a text like this: A1JOURNEY0TO1 .BYTE 00, 00, 00 A2JOURNEY0TO2 .BYTE 00, 01, 00 A3JOURNEY1TO0 .BYTE 00, 01, 01 I need to have: JOURNEY_01 ; 00 TO 01 ...
1
vote
1answer
190 views

Unix Solaris script for executing commands in multiple remote hosts

I have two hosts for eg. 1) 00.00.00.01 having regions on diffrent ports for eg. a) a1region (port 0011) b) b1region (port 0012) c) c1region (port 0013) 2) 00.00.00.02 having regions on diffrent ...
3
votes
3answers
152 views

rename(1)-like script in Perl, but for copying files?

So there's this rename(1) Perl thing. It suits my task precisely, except that I need it to basically cp files instead of mv. How to achieve that? I have quite a few rules of renaming, all expressed ...
0
votes
1answer
1k views

Extract value from different column and replace in another column

I need to do this: ##fsdfsd ##sdd-ver gen 5.5.7 Xm Gen CDS 1 148 . + . Name=;created by=User;modified by=User;ID=Bm Xm Gen CDS 149 193 . + . ...
5
votes
6answers
4k views

sed command to swap characters

My input file layout is: mm/dd/yyyy,hh:mm,other fields I need to format it as: yyyy-mm-dd hh:mm:00,other fields sample input: 01/02/1998,09:30,0.4571,0.4613,0.4529,0.4592,6042175 01/02/1998,09:45,...
-3
votes
1answer
41 views

i have a file with random numbers. i need to convert all numbers from 2000-4000 to xyzw [closed]

Example input: 2234 1233 5678 8876 9009 3444 2222 3454 5667 7878 4554 3222 Output: xyzw 1233 5678 8876 9009 xyzw xyzw xyzw 5667 7878 4554 xyzw I am using this query: perl -pe 's/^[2-4]+/abcd/g' ...
0
votes
2answers
70 views

Making multiple lines as single lines

I have below 4 lines: EXTRACT ETEST Last Started 2016-03-20 20:56 Status RUNNING Checkpoint Lag 00:00:02 (updated 00:00:04 ago) EXTRACT PTEST Initialized 2016-03-31 06:25 Status ...
0
votes
1answer
840 views

Parse header in a file and based on the header replace a value in the file

I have the following file Field1|Field2|Field3|Field4|Field5 a|b|c|d|e 1|2|3|4|5 z|y|x|w|v I have a script which accepts two inputs script.sh Field3 T The script.sh would take the 'Field3' ...
0
votes
4answers
161 views

Extract ranges of lines from a file, saving each range to a separate file

I have a file that looks like this 740*02/01/2016*00:00* EJ LOG COPIED OK AUTO INIT COPY DRIVE NOT CONFIGURED E1EF3901 [020t*741*02/01/2016*05:45* *TRANSACTION STARTED* [020t CARD INSERTED [...
-2
votes
1answer
47 views

Perl script which operates on an input file

I am trying to write a script which takes a file as input, reads each line of that file, performs a find based on the value of the file contents, and writes the output to a different file. What I have ...
0
votes
1answer
87 views

Replace the string as $test

I am having many text file with different directories. I need to search one specific string and I need to replace the string with the specific value as $test. I need to search the all files in all ...
0
votes
2answers
70 views

Printing out users without /home directories and /home directories without users

I need to develop a perl script that will generate a formatted listing of any user without a home directory and any home directory that is not attached to a user. For example, if I used the script ...
0
votes
1answer
154 views

Perl script for generating MAC addresses

This perl line very useful to change mac address but retain the first three pair. perl -e 'for ($i=00;$i<6;$i++){@m[$i]=int(rand(256));} printf "00:16:3E:%X:%X:%X\n",@m;' Generate some good ...
0
votes
1answer
84 views

Identifying an API

NetApp Tech Support is assisting me with an SDK issue between Nagios and a filer cluster. One question he asked me is, 'What API are you calling when you run /usr/local/nagios/libexec/...
0
votes
2answers
72 views

Data arrangement

I have data which i would like get output in below format using shell/perl script. Data: Virtual Machine Test status Running. Assigned Server OVS001.local Virtual Disk Test_DISK1 (30) size 61GB ...
1
vote
2answers
2k views

What scripting language or platform to use for web page downloads and screen interaction?

Possible Duplicate: Does anybody here have experience in automating some tasks in web applications using curl? Here is what I need to do? Wondering what platform is most suited - easy to ...
4
votes
3answers
306 views

Get one thing from a line and concatenate it with one thing from another line

I have the following: 2018-11-10 23:57:21 [COMMAND]: sar -u 10 5 AIX host 1 7 11/10/18 System configuration: lcpu=64 mode=Capped 23:57:21 %usr %sys %wio %idle physc 23:57:31 ...
5
votes
2answers
666 views

Perl command line regex to modify all pattern matches

I'm trying to use some arithmetic over the matched patterns in perl command line. I'm able to do it for one match but not for all. str="a1b2c3" perl -pe 's/\d+/$&+1/e' <<<"$str" a2b2c3 ...
1
vote
3answers
181 views

Find or extract text between two patterns either on the same line or in many lines

I need to print the text between two patterns without keeping in mind their place as they are found randomly across the file. either in the same line or not in the same line or a text occur between ...
2
votes
0answers
34 views

How do I display file modification time (linux) as “Nov 8 12:00” format? [duplicate]

The format I want is "Nov 8 12:00". It is the format you get by using the ls -l command. It is month, day of the month, hour and minute. I tried stat -c %Y filename which gives time of last data ...
12
votes
3answers
922 views

Is there a way to make perl -i not clobber symlinks?

A friend of mine points out that if you do: perl -pi.bak -e 's/foo/bar/' somefile when "somefile" is actually a symlink, perl does just what the docs say it will do: It does this by renaming the ...
2
votes
1answer
96 views

Can I change terminal type used to login through Net::SSH in perl?

When I login on some particular server through Net::SSH in perl (which I do not have admin access to), I get the following error: %SECURITY-SSHD-4-WARNING_LOGIN : The requested term-type '' is not ...
1
vote
1answer
178 views

Install program with Perl?

I'm trying to install GTK YouTube Viewer from GitHub (https://github.com/trizen/youtube-viewer) in Q4OS (Debian-based). I downloaded the .zip file and extracted it, then tried to run the first ...
-1
votes
5answers
385 views

Need a awk/sed to replace the values present inside ${}

I am trying to do url testing by fetching the values from env.properties file. For example, my env.properties will look like this a.host.name=wanx.com b.host.name=xyu.com c.host.name=${b.host.name} ...
0
votes
1answer
46 views

Replace any string after the last dot with txt string

how to replace any string after the last "." to txt for example filter.bash sum.sh portG.py run.doK.ksh expected results filter.txt sum.txt portG.txt run.doK.txt
13
votes
2answers
20k views

Replacing missing value blank space with zero

I have input.txt tab-delimited text file around 30K lines, I would like to check each row (s1..s30K lines) for missing value (i.e blank space) and fill the missing value with zero value.See out.txt ...
1
vote
1answer
69 views

edit names in phylogenetic tree in newick format [closed]

I have a phylogenetic tree in newick format, and I would like to remove some fragments of the name of the taxa, 1_[genus_specie_1]_characters:0.2654682758,(((((((((((((((2_[genus_specie_2]...
0
votes
2answers
146 views

How to swap two fields inside a JSON file

I have a file like this {"100":["0.00001","10","0.01"], "101":["0.0001","100","0.1"], "102":["1","1000","1"], .... "103":["0.01","10000","10"]} I want to swap the second number with the third, ...
1
vote
3answers
3k views

split string to two parts using sed or awk or perl or bash

I have string like this: Grades ABCDEF-123456 I want to split this string to two sections like this Grades ABCDEF Grades 123456 How can I do that in bash?
6
votes
2answers
1k views

Perl script running infinitely - how to debug what happened?

I am running a Perl script on a Linux machine via a cron job. However, from time to time (around 1% of all cases), the script gets stuck and runs infinitely. If I list processes, I can see its PID. ...
0
votes
2answers
72 views

how to print the matching value from same line, which has multiple Delimiter?

I have a File under Linux /tmp/volume.log and the content is: [id:1091666, name:root, deviceName:/dev/sda, maxStorage:107374182400, unitNumber:0, displayOrder:0, rootVolume:true],[id:1091851, name:/...
6
votes
2answers
10k views

Fetch values from plist file on Linux

I have bash script which was written for OS X and now ported to Linux. I don't have access to the Linux box. The bash script would read values from plist files using the defaults read and PlistBuddy ...
-3
votes
3answers
163 views

How to grep or search 3 word Patterns in a file and print them along with the content between second and third word Pattern [closed]

How to find or search word PATTERN1 and PATTERN2 and print them both later i want to search PATTERN3 and Print the whole content or section between the search PATTERN2/PATTERN3 (Note Pattern1/2/3 ...