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 ...

learn more… | top users | synonyms

0
votes
3answers
32 views

awk or sed or perl: remove only characters on specific position

I have multiple files to rename leng-1494-001 leng-1464-002 leng-2414-004 leng-7894-005 leng-1323-006 I want to rename it ferr-1494-001 ferr-1464-002 ferr-2414-004 ...
0
votes
0answers
9 views

Compilation fails with Padre (a Perl IDE) on RHEL-based distros (CentOS, etc.)

I tried: # as root yum install cpan perl-ExtUtils-Embed # as normal user cpan Padre But failed: [usernamehere@notebook ~]$ cpan Padre CPAN: Storable loaded ok (v2.20) Going to read ...
0
votes
0answers
15 views

Comparing two text files and printing out matching ids, sub_ids and timestamp related to the id

I found this solution in Perl interesting. I have a similar situation to print matching columns and two additional columns from the second file (Rev ID n date released). How do I read both files from ...
3
votes
1answer
45 views

What are the 'n', 'l', '3pm' sections of the manual for?

An excerpt from the man man page: The default action is to search in all of the available sections following a pre-defined order ("1 n l 8 3 2 3posix 3pm 3perl 5 4 9 6 7" by default) What are ...
2
votes
1answer
24 views

Adding consecutive characters to duplicate words according to order they appear

So I have files like this but for hundreds of different genes per file. >lcl|accession_cds_proteinaccession [gene=dnaA] [protein=description] [protein_id=accession] [location=location] ...
2
votes
1answer
184 views

Perl /Sed replacement

Below command is used to replace the password in a script but the perl command is adding a white space when it does the subsstitution password=arche20 perl -i -p -e "s/^(password[]*=[ ]*).*$/\1 ...
1
vote
2answers
24 views

To Regex Pandoc Tables

Minimum Data to regex \documentclass{article} \begin{document} ------------------------------------------------------------- A B C D Header Aligned Aligned ...
0
votes
0answers
33 views

Code for creating charts from csv data in shell - pure scripting

I am running mysql queries and put the data in csv file and mailing the same using shell script.[This is an automated script] I want to create a chart out of the csv data and put it in the mail body ...
-2
votes
0answers
45 views

Convert perl to shell/bash [closed]

I understand C and C++ and new to perl scripting. I must convert the perl script under the following url to shell or bash: busware Here is the code: #!/usr/bin/perl use warnings; use strict; use ...
-2
votes
0answers
12 views

How to generate a unique reference& increment for each row into an existing script which generates a csv file [closed]

I have a perl script which generates a csv file with different columns, in which values are retrieved from a database/server. I would need to add 1 more column which should generate a unique reference ...
0
votes
0answers
35 views

Installing custom RPM says “does not update installed package”

I've inherited some servers which have previously always had its software as custom compiled versions (apache, perl, mod_perl etc). I was thinking than rather than compile every time, it may be better ...
-1
votes
0answers
12 views

Trouble with sudo yum install mod_perl

sudo yum install mod_perl Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * rpmforge: mirror.hmc.edu Resolving ...
5
votes
1answer
177 views

Replace non-printable characters in perl and sed

I need to replace some non-printable characters with spaces in file. Specifically, all characters from 0x00 up to 0x1F, except 0x09 (TAB), 0x0A (new line), 0x0D (CR) Up until now, I just needed to ...
2
votes
0answers
22 views

Any sumfunc in Perl by default [migrated]

Code sub sumfunc { my (@x) = @_; my $sum = 0; for(my $i=0; $i<=$#x; $i++) { $sum += $x[$i]; } return $sum; } Use my $Sx = sumfunc(@x); How can you do sumfunc better? ...
0
votes
3answers
24 views

To improve this regex about digit separation

Code m/([+-]?\d+\.\d+)[\s\t]+([+-]?\d+\.\d+)/ Data 22.585698 3601.767090 D:\measurements\LabCourse_2015\6\90deg\image0001_23_mT.png 20.051883 3580.268555 ...
1
vote
1answer
36 views

Synchronize columns of two matrices

Please guide on how to solve this problem. I have pairs of files which I need to modify so that they have the same common columns in the same sequence. If my files are File1 and File2 as follows ...
0
votes
1answer
100 views

“Cannot install Nagios::Plugin, don't know what it is.”

I used this command to install Nagios::Plugins on multiple servers months/weeks before: perl -MCPAN -e 'install Nagios::Plugin' Now I get this error message: Reading '/root/.cpan/Metadata' ...
1
vote
1answer
38 views

Merging rows with common values

I am trying to combine pairwise matches in a text file so that i can find all matches in a group: e.g. my file contains two tab separated columns like this: Simon John Simon Paul Steve Simon Graham ...
0
votes
1answer
36 views

Multiple input files and output files in awk

I have a folder full of text files named 000.txt to 181.txt. How can I process all of them with the same awk script (program.awk) and send them to their respective output files (output000.txt - ...
0
votes
1answer
63 views

make a table output

if it possible to do a snmpwalk in a perl script and put the output in a table to make a sort of association like for each hostname i have in the same line if index and desc i have the script in bash ...
2
votes
2answers
42 views

Release memory in perl script

I want all this combinations but I don't have enough memory. How can I release memory in my script? use strict; use warnings; use Algorithm::Combinatorics 'variations_with_repetition'; my @let = ...
3
votes
3answers
81 views

Match lines of a file with headers in other to obtain entire para

I want help with scripting to work with two files, wherein file 1 lists amino acids which are in specific order (one below the other and also might repeat) and the second file 2 constitutes the ...
0
votes
3answers
63 views

Filtering multi-lines from a log

Should this question be moved to stackoverflow instead? I often need to read log files generated by java applications using log4j. Usually, a logged message (let's call it a log entry) spans over ...
-5
votes
2answers
63 views

How to average a column in a text file without using ' character? [closed]

I need to do it without using the ' character. I could do it like this: awk '{sum+=$5} END { print "Average = ",sum/NR}' except this contains a '.
3
votes
4answers
506 views

Is is possible to modify a file in a read only directory? [duplicate]

I have already read: Is there a way to modify a file in-place? I am curious if there is a way to modify a file in place using a command that will not create temporary files. Let's say I create a ...
2
votes
2answers
39 views

Perl non-greedy regex matching more than it should

I have the following text from which I need to remove some wdiff output. text='Иса Мәсіхтің елшісі Петірден [-(-] осы күнәкар дүниеде [-)-] жат жерлік болып, Понти, Ғалатия, [-Қападоқия, Азия және ...
4
votes
3answers
132 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 ...
0
votes
4answers
66 views

How to remove line based on Delimeter in perl / Shell?

Can anyone help to remove the line in file based on delimeter(Comma), Incase if line contain less number of columns or Bad records , Need to delete those. Input File: a,b,c,d a,b,d,f c,d a,v,b,h ...
-1
votes
1answer
35 views

Spreadsheet::ParseExcel [closed]

I am using Spreadsheet::ParseExcel, and want to take the file name as an input from the user. Moreover, I want the parsing of two files to happen based on a condition provided by the user. This is ...
12
votes
9answers
3k views

Is using “while true” to keep a script alive a good idea?

I'm just jumping into unix from a different world, and wanted to know if while true do /someperlscript.pl done The perl script itself internally has a folder/file watcher that executes when ...
1
vote
1answer
39 views

How to match parameter and replace the value after “=” separator

the perl one liner command to replace Value in file is simple: perl -i 's/oldval/newval/g' file.txt but what should be the perl one liner syntax in case we want to replace the value on specific ...
1
vote
1answer
45 views

awk script to rearrange similar rows

I want rearrange about 5 million rows (with 300 columns) into groups. Data looks like the following: where there were various experiments (column 2) conducted at different locations (column headers ...
-1
votes
1answer
46 views

Is it possible to get static backreference with grep?

I try to match a a group twice in multiline. grep -Pz 'Source: (?<group>.*/).*\n.*\n.*\n.*\k<group>|$' it work except one major problem - it doesn't, \k<group> search for .*/ and ...
4
votes
2answers
64 views

How exactly does perl's -0 option work?

According to man perlrun: -0[octal/hexadecimal] specifies the input record separator ($/) as an octal or hexadecimal number. If there are no digits, the null character is the ...
0
votes
1answer
28 views

How to pass parameters in a cgi-perl on Fedora 20?

I'm using Apache server on Fedora-20. I'm trying to run a perl-cgi program on my local server, but it's not working, I have attached my html and perl code. html program: <html> ...
1
vote
1answer
211 views

bash bad interpreter and permission denied

I installed RHEL 5.1 on a virtual machine. I would like to install VMware Tools, but I keep getting an error. I am performing the installation via the tar procedure. I get the following error: bash: ...
2
votes
3answers
114 views

How to run multiple scripts in parallel

I have one bash script which calls the same perl scrips in a serial way. The bash script is used to collect the overall results, while the perl script collects the results of my simulations for the ...
3
votes
2answers
269 views

remove ^M from solaris by perl one liner on the same file

usually in order to remove the ^M from file we do dos2unix test.txt test.txt tr -d '\r' < old.file > new.file but this approach insist to create new file if we do not want to create another ...
1
vote
3answers
170 views

how to delete line from the XML file

how to delete only the line from xml file ( with sed/awk or perl one liner line ) that start with: <units> and ended with </Networks> as the follwoing <units><unit ip= ...
1
vote
1answer
64 views

smd5 - generate by unix tool or perl

I have problem on Unix, have to create a lot of passwords in smd5 but don't know how to generate smd5 passwords using some unix tool or perl in a form: {smd5}DoZgZ.OE$vSg4ZH7Bpy0BCdXNzBj001 I have ...
1
vote
1answer
54 views

How to pass a path to a file through a call to perl from bash?

This is a more advanced version of a previous question (How to pass arguments to perl when trying to change a line?) I made. This time I am trying to pass a path, but evertything seems that the the ...
0
votes
2answers
35 views

How to pass arguments to perl when trying to change a line?

I am using the approach suggested in http://askubuntu.com/questions/434051/how-to-replace-a-string-on-the-5th-line-of-multiple-text-files to modify the first line of an archive. Let's suppose the ...
4
votes
1answer
38 views

ack.pl tool and ack.pl flags

I am using the ack.pl tool in order to search string or IP’s in files The official site of ack.pl is - http://beyondgrep.com/documentation/ Example of ack.pl CLI ( want to find the string ...
0
votes
5answers
144 views

To remove \n but not \n\n

Data 23. Lorem A) he B) ha C) hu c 2. Ipsun yes right to write something here? A) Ok B) No C) yes b 292. Ipsun A) Apex B) hello b 289. He A) hu B) Ha C) He The right answer is: 1) Ab 2) Abc 3) ...
1
vote
1answer
35 views

How do I synchronize 2 xml files?

I have 2 xml files named 1k.xml and 1n.xml. The file 1k.xml contains some additional elements and data which are not there in 1n.xml. I want to copy whatever is absent in 1n.xml to it, so that both ...
0
votes
1answer
54 views

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

I have a problem I need help with. I'm not very experienced with awk, but it seems to be a good tool for this job. I have the following file Field1|Field2|Field3|Field4|Field5 a|b|c|d|e 1|2|3|4|5 ...
1
vote
1answer
46 views

How to print incremental count of occurrences of unique values in column 1

I'm trying to come up with an solution to this problem, I need to incrementally count and then print the counts of the unique values in column 1 of a tab delimited text file. Here is an example: ...
2
votes
1answer
53 views

nix package manager: perl warning: Setting locale failed

Whenever I run a command for the nix package manager (e.g. nix-channel --update) I get the following warning: perl: warning: Setting locale failed. perl: warning: Please check that your locale ...
5
votes
2answers
143 views

Transpose a file, and replace missing values

I have Readings for Names, from Machines and sometimes these readings are replicated. Where a reading was not found, it is left as blank. Name Instrument Rep R1 R2 R3 N1 I1 1 1 2 3 N2 I1 1 1 3 4 ...
1
vote
1answer
19 views

Rename command with non-existing target directory

I'm trying to group files automatically into subdirectories using a command like this: $ rename 's/(.)(.)(.+)/$1\/$2\/$1$2$3/' *.* A dry run with the -n parameter shows me what I want: test.jpg ...