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
1
vote
2answers
125 views

RegEx for replacing capture group content using sed [closed]

Have inputs.conf files in multiple directories that needs to match and parse each stanza and modify the index= to index=secure. This are files type in inputs.conf and also do run the script to locate ...
0
votes
3answers
210 views

Replace block of text with sed, awk, perl or vim

I am trying to replace every instance of a block of six rows with another block of six rows, just reducing the six rows block of two columns to a six rows block of only one column. Thank you to your ...
0
votes
0answers
31 views

Bash-Perl Make Substitution and Return array (string & number of replacements/substitutions)

I have this code that makes substitutions in a file segment. The code should be left mostly unharmed except for this problem. I need to return back to bash, the number of replacements made by perl ...
-2
votes
3answers
60 views

Perl multiline match for 'something' which starts without '#\s'

UPDATE: The REAL answer to this MULTILINE question was given here by Stephane https://unix.stackexchange.com/a/521560/354415 Alternatively go line by line with perl by Terdon below: https://unix....
0
votes
2answers
86 views

Perl Negative Lookbehind with variable length bypass maybe?

I have this simple code perl -we 'my $file= " # parameter=10 # parameter=10 # parameter=10 parameter=10 parameter=10 "; $file=~ s/((?<!# ))\s*parameter\s*=.*/parameter=replaced/g; ...
6
votes
2answers
114 views

number headings

I need to convert whitespace to a tiered, numbered list and have found this elusive. This is the sort of thing I'm after: Input (visible): Project #1 Subproject Task ...
33
votes
10answers
59k 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" line4-...
2
votes
1answer
55 views

Perl Script in Bash Here Document (does not output variable)?

How come the following perl code, mkdir("foo"); print "foo: $!\n"; mkdir("foo"); print "foo: $!\n"; Will output the following (in a directory without a foo) perl ./asdf.pl foo: foo: File exists ...
9
votes
5answers
62k views

How to convert from one date format to other format?

I have one problem with my date format. I want to change from one format to the other and vice versa. My date formats are Format 1 YYYY-MM-DD Format 2 MM/DD/YYYY I want to change format 1 to ...
0
votes
0answers
28 views

How to create RPM for generic Perl module

I have a generic Perl module that will run on any release of Perl 5. I need to create an RPM for it that will install it into the vendor_perl subdirectory. I don't want to create different RPMs for ...
0
votes
2answers
62 views

How to remove repetition of the content of file by column?

I have a file containing the following content: WP_021815421.1 OG5_132922 deth|YP_182312 3 -07 42.35 81.7 WP_021815427.1 OG5_128110 rbal|NP_868155 1 -55 50.72 53.2 WP_012456834.1 ...
2
votes
2answers
77 views

Perl regex to recognize multiple strings

I have a file ~/foo.txt that has instances of each of the following strings alpha-1 alpha-2 alpha-3 alpha-4 alpha-5 alpha-6 alpha-7 alpha-8 alpha-9 I would like to replace each of these alpha-X with ...
0
votes
2answers
145 views

Why is my multi-line perl string replace adding a blank line?

I'm trying to replace multiple lines in a text file (an XML element with an unknown number of children) with the contents of a separate text file. I've managed to get the replace mostly working using ...
0
votes
1answer
109 views

Perl: replacing commas between quotes with @ symbol

I have this tricky text block where some ending quotes appear on the next line. I want to replace every comma appearing between quotes with @ symbol. "----, ----",, ----, ----,,"",start quote," ...
3
votes
2answers
2k views

No idea how to troubleshoot Bugzilla email issue

I have a Bugzilla 4.2.4 install that is now unable to send email. It was able to send email without issue up until about a month ago (after about three months without issue). If someone posts a ...
0
votes
2answers
54 views

compare two column of two different CSV file & merge the output

TABLE1.csv DATE, TIMESTAMP, ID, START TIME, END TIME, DURATION 2019-04-05, 13:57:19, 1607,13:06:42, 13:07:12, 00:00:30 2019-04-05, 13:58:00, 2327,13:57:26, 13:57:43, 00:00:17 2019-04-24, ...
0
votes
1answer
101 views

Calculate the time difference between two columns in time format hh:mm:ss

I want the time difference between column 5 & column 4 My Input: DATE TIMESTAMP ID START TIME END TIME 2019-04-05 13:57:19 1607 13:06:42 13:07:12 2019-04-05 13:58:00 2327 13:57:26 ...
0
votes
0answers
73 views

Why the distr instmodsh cannot list the installed distr/vendor_perl modules ?

We find such a phenomenon with the instmodsh, that is, it can only list the installed CPAN modules ?! So why it cannot list the installed distr/vendor_perl modules though itself belongs to a distr ...
1
vote
2answers
55 views

Howto find the size of a remote http/https directory (non recursively) using a given regexp from the command line

I'm trying to find the size of a remote http/https directory (non recursively) using a given regexp (\.mp4) from the command line, is there a tool to do so or do I need to parse the index.html ? ...
-1
votes
2answers
98 views

How to make code interpret $ but not *? [closed]

I have some perl code (don't focus on what it does right now, i'm still working on it): #!/usr/bin/perl -w if(!@ARGV) { print ("ERROR: NO ARGS\n"); exit 1; } else { use Cwd qw(cwd); my $dir ...
0
votes
5answers
162 views

How can I change the character of a string one by one?

I want to change all the characters in string one by one according to the substitution rule and save them to file on Linux. This is substitution file (sub.txt). A -> Y B -> V C -> Q ... ...
-2
votes
2answers
57 views

How to remove entire array that have specific character

I have a perl code that extract from .xls file. My .xls file is as below NUMBER NAME ALPHABET one Jane a two Adam b three Josh c ;four five Agnes ...
17
votes
7answers
46k views

Repeat each line multiple times

Would like to have each line in a file repeated a fixed number of times. e.g. have each line repeated four times: a b c becomes: a a a a b b b b c c c c I've done some searching, and there are a ...
5
votes
3answers
8k views

piped program in sendmail's /etc/aliases

I'm trying some sort of auto-subscription via a homegrown script. I know it can be achieved by mailing lists such as Mailman but I also want to learn at the same time on how to do it by hand. Here's ...
7
votes
8answers
1k views

Delete nth line (when counted from the bottom)

There are unknown number of lines in a file. How to delete nth line (when counted from the bottom) with one-liner command (you may use more than one if it is necessary) on Unix platform.
1
vote
2answers
67 views

fastest way to subsitute on 10GB file for multiple expressions

I have a file of 10GB data, I want to execute 2048 substitution expressions of sed -i 's/pattern/replace_pattern/g' on that file. Is there a way to do it faster and effectively. Currently, I am ...
-1
votes
3answers
3k views

Find files less than 1 week old with match TODO in files

My unsuccessful proposal find ./ -newerct '1 week ago' -print | grep TODO No output although should be. Files are text files like Lorem % TODO check this out Lorem ipsun How can you find less ...
1
vote
2answers
2k views

Parse XML file to copy the content into another file at a particular spot in the file?

I have an xml file (client_23.xml) in which I need to add few lines at a particular section basis on what is there in other xml file (abc_lop.xml). Here is my abc_lop.xml file in which you see I have ...
0
votes
3answers
215 views

Grep end regex matching

On OS X, system_profiler SPHardwareDataType outputs: Hardware Overview: Model Name: MacBook Pro Total Number of Cores: 4 L2 Cache (per Core): 256 KB L3 Cache: 8 MB Memory: 8 GB I want to ...
1
vote
4answers
1k views

Change specific part of file via a shell script

What is the simplest way to search for a word in a file given in the command line, with this format ./<file1> -f <file2> --edit <id> <column> <value> I want to search a ...
2
votes
2answers
620 views

How do I install the Perl module File::HomeDir on Arch Linux?

I need to install the Perl module File::HomeDir on a laptop running Arch Linux. In order to find out which (pacman-)package contains that module, I run pkgfile -u pkgfile HomeDir.pm The second ...
0
votes
1answer
32 views

Replace middle of filepath while keeping filename at the end?

I am trying to manipulate a file path using bash. The first part of my goal has been completed, where I replace the first half of the file path with the path on my local computer. $> fp=$"/...
0
votes
1answer
51 views

Replace group of similar text in string from nth position with one string else increment the value by +1

I have a text file with following lines for example. Input DD0TRANSID000019021210504250003379433005533665506656000008587201902070168304000.0AK 0000L00000.00 N ...
0
votes
3answers
282 views

Replace text in lines in a file with increments

I have a file with multiple lines (no. of lines unknown) DD0TRANSID000019021210504250003379433005533665506656000008587201902070168304000.0AK 0000L00000.00 N 01683016832019021220190212N0000....
0
votes
2answers
80 views

How to append line with strings at the end of variable?

We have the following line in file more file USA_FORMAT="-XX:LOP83746=5M -XX:+YU3635-2837" and we want to append the following strings (line) also at the end of USA_FORMAT variable /usr/jdk64/...
1
vote
6answers
206 views

how to capture specific strings from line

How to capture only the sdX from the following line using bash, awk, sed or perl in one liner command? echo ""dfs.datanode.data.dir" : "/rid/sdb/oo/hdfs/data,/rid/sdc/oo/hdfs/data,/rid/sdd/oo/hdfs/...
0
votes
0answers
13 views

Log4perl Fails on Linux Lite

I recently re-purposed an old laptop of mine by popping in a new SSD and installing the latest stable version of Linux Lite. I've been trying to get my preferred configuration of Atom running on it. ...
1
vote
3answers
79 views

delete lines matching pattern if it is repeated

Say I have a config file: [main] foo = bar [option] opt1 = opt2 opt3 = opt4 [extra] [footer] [tail] print = true [end] I want to print the headers ([text]) only if there are options underneath. So ...
0
votes
2answers
1k views

How to install Perl modules on Debian 9?

On a tutorial for installing SendEmail, I found instructions to install 2 prequisites, 2 perl modules apt-get install 'perl(Net::SSLeay)' 'perl(IO::Socket::SSL)' This syntax also resulted strange to ...
1
vote
3answers
12k views

compare two files based on a column and print it

I have two big files of 400,000 lines. I want to compare the column 1 of the second file with column 1 of first file recursively. If they match I would like to print the whole line. It is a sorted ...
1
vote
4answers
236 views

Remove only given strings from given column?

INPUT: <tr><td>FOOBAAR</td><td>FOOO</td><td>BAAR</td><td><font style=BACKGROUND-COLOR:red>2014-02-14 13:34</font></td><td><...
-1
votes
3answers
73 views

how to assign values to intervals with overlapping regions?

I have two big files, the first file contain some intervals with 85K rows: head data.intervals id id_uniq numberA numberB 1 g1 5 20 1 g2 6 29 1 g3 17 35 1 g4 37 46 1 g5 50 63 1 ...
2
votes
1answer
73 views

uniq -c Equivalent for Groups of Lines of Arbitrary Count

I've got a file of ~1-2 million lines that I'm trying to reduce down by counting duplicate groups of lines, preserving order. uniq -c works okay : $ perl -E 'say for (("foo") x 4, ("bar") x 4, "baz"...
5
votes
7answers
5k views

Insert a word in the first line of the file

Input: firstline secondline thirdline ...some magic happens here... :) Output: insertedtextfirstline secondline thirdline Question: How can I insert the insertedtext to the start of the first ...
1
vote
4answers
330 views

How to repeat a row for each value of its corresponding column

I want to repeat a row for all its corresponding values any help my input file is like this pos COL1 COL2 COL3 18691441 C A G 18691572 G C G 18691620 A T ...
0
votes
2answers
474 views

Find lines between two patterns and append lines with pattern

We have the following file where a bunch of records (million records) of interest are between the start and end of patterns. The start pattern always start with an A and the end pattern always starts ...
2
votes
0answers
131 views

'Out of Memory' on AIX installing Perl Module [closed]

Getting out of memory error trying to install NetFTPSSL perl module on IBM P750 running AIX 7.1 with 76GB of memory. root@polarprod-cip(/)# perl -MCPAN -d -e 'install Net::FTPSSL' Loading DB ...
0
votes
1answer
187 views

amavisd: Unrecognized character \xBB;

I have a problem to start the amavisd. When I try to start with /etc/init.d/amavis start I get the following error: Starting amavisd: Problem in Amavis::DKIM code: Unrecognized character \xBB; marked ...
3
votes
2answers
2k views

how to apply this patch

There is a patch fix for perl module net::ssh2 it fixes a seg fault error that happens on some machines. It's located here: https://rt.cpan.org/Public/Bug/Display.html?id=36614 I downloaded the ...
0
votes
1answer
409 views

perl(Inline) module is needed

I decided to view the contents of buffers cache using the tool called fincore while trying to install I have been getting the error as warning: fincore-1.9-1.el6.rf.x86_64.rpm: Header V3 DSA/SHA1 ...