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
1answer
24 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
39 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 ...
5
votes
2answers
119 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 ...
2
votes
2answers
36 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
77 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
2answers
1k views

Failed dependencies trying to install package 'libxml2'

I am trying to install libxml2, but my system complains about dependencies. The dependent packages exist on system. The ultimate goal is to install xml_grep2, I have been trying various methods ...
0
votes
3answers
47 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
59 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
480 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
35 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
123 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 ...
1
vote
3answers
6k views

compare two columns of different files and print if it matches

I am using solaris 10 and Grep options involving -f doesnt work . I have two pipe separated files: file1: abc|123|BNY|apple| cab|234|cyx|orange| def|kumar|pki|bird| file 2 : abc|123| ...
0
votes
4answers
59 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 ...
0
votes
1answer
811 views

How to convert XML file to CSV using Perl?

I'm looking for some suggestion to convert the .asn1 (CDR Data) to CSV to load to tables. As per current approach I'm using informatica B2B parser to parse the ASN file to XML than using XSD loading ...
2
votes
4answers
99 views

How to highlight given string in given place?

How can we modify this: <a href="http://foo.bar1">asfdlksafbar1qsasadf</a><br> <a href="http://foo.bar2">svasfbar2saldkfj</a><br> <a ...
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 ...
61
votes
2answers
110k views

How can I replace a string in a file(s)?

Replacing strings in files based on certain search criteria is a very common task. How can I replace string foo with bar in all files in the current directory? do the same recursively for sub ...
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 ...
-1
votes
1answer
30 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 ...
5
votes
6answers
5k views

How to insert the content of a file into another file before a pattern (marker)?

File1 contents: line1-file1 "1" line2-file1 "2" line3-file1 "3" line4-file1 "4" File2 contents: line1-file2 "25" line2-file2 "24" Pointer-file2 "23" ...
1
vote
1answer
36 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
35 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 ...
8
votes
5answers
5k views

How to remove multiple blank lines from a file?

I have some text-files I use to take notes in - just plain text, usually just using cat >> file. Occasionally I use a blank line or two (just return - the new-line character) to specify a new ...
-1
votes
1answer
40 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
58 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 ...
1
vote
1answer
2k views

“Requires: perl(:MODULE_COMPAT_5.8.8)”

I use CentOS 6.5 for my server with below repository: IUS epel ces-standard-* base/upgrade/extras When I tried to update today (it's been a while I haven't updated this server), I got the ...
0
votes
1answer
24 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
49 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
51 views

Neutralisation of data from Windows to Unix

I just noticed that other platforms files (Windows) had to cause me many bugs, like here, in my regexes. Mostly, the line ending ^M. There seems to be many ways to do dos2unix, like here described. ...
1
vote
1answer
123 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: ...
3
votes
2answers
244 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 ...
2
votes
3answers
90 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 ...
1
vote
3answers
137 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
32 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 ...
1
vote
4answers
125 views

How to insert a variable in a variable in a random place?

Q: How can I insert variable $b to a truly random place in variable $a? Example INPUT variable content: $ echo $a árvíztűrő tükörfúrógép $ echo $b ZZ OUTPUT $ ./somemagicscript.sh árvíztűrő ...
19
votes
3answers
12k views

What does ${1+“$@”} mean in a shell script, and how does it differ from “$@”?

In the Perl documentation, perlrun(1) suggests launching Perl scripts using a bilingual shell/Perl header: #!/bin/sh #! -*-perl-*- eval 'exec perl -x -wS $0 ${1+"$@"}' if 0; What does ${1+"$@"} ...
1
vote
1answer
48 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
32 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 ...
2
votes
5answers
843 views

Print the string between two parentheses

I have file with these lines G8 = P(G1,G3) G9 = P(G3,G4) G12 = P(G2,G9) G15 = P(G9,G5) G16 = P(G8,G12) G17 = P(G12,G15) I need the output as G1,G3 G3,G4 ..... How can I do it with sed/grep ...
0
votes
1answer
47 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 ...
0
votes
5answers
132 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
36 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
39 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 ...
0
votes
1answer
65 views

What “bad list v: No such file or directory at -/usr/libdata/per15/OpenBSD/Pkg_Add.pm line 1115” means?

I recently installed OpenBSD on an old laptop from 2005 and I am trying to install nano and then xfce4 and then a few other programs, but every time I try to use pkg_add, I get the message: Fatal ...
1
vote
1answer
18 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 ...
0
votes
1answer
25 views

how to change several piece of html code

I have several chunks of html code ,see below, in a html page that I need to change Assurez-vous de bien recevoir tous nos messages en ajoutant bebeco@concretisezvosprojets.com à votre carnet ...
2
votes
2answers
43 views

How do I extract the content of quoted strings from a file

have a file which looks like this: anm="12S123S" family="" type="Std" product="" name="nand" allow="yes" anm="12321 S=" family="" type="Std" product="" name="dan" need="No" anm="SWED" family="" ...
3
votes
5answers
2k views

Replacing text from a list of replacements. Added complication: backslashes

I have a file A that contains pairs of strings, one per line: \old1 \new1 \old2 \new2 ..... I would like to iterate over file A, and for each line perform the replacement (e.g. "\old1 -> \new1") ...
2
votes
1answer
51 views

how can I add an extra character after a word search [closed]

I have the following field names demelog voyapro naisjdf naismc decoide decoccm travide travccm equiccm mariccm Below is a sample of my file. There are more columns before the first fck=83... ...
7
votes
5answers
13k views

invalid SSL_version specified at /usr/share/perl5/IO/Socket/SSL.pm line 332

Since I upgraded my PC from (k)ubuntu 12.04 to 12.10 I receive this error message when trying to send an email using sendemail. Installing an older version of IO::Socket::SSL is not an option. I ...