Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
13 views

How to create separate files based on first column value? [duplicate]

It is tab separated 3 column file. I need to create separate files based on first column value Input: 194501 CAD 1.47421052631579 194517 CAD 1.39578947368421 194520 CAD 0.949473684210526 194501 ...
-2
votes
1answer
54 views

how to match single pattern and replace it with multiple pattern in perl [on hold]

i have one file which contain following info - input - a[1]= something_data_1; a[2]= something_data_2; a[3]= something_data_3; so i want to replace that "a" with different pattern like below, ...
1
vote
1answer
39 views

mkdir command not found?

I think I messed up the PATH. I was installing Bioperl and tried to changed path. The correct code should be: $ export PATH=/usr/local/ActivePerl-5.26/bin:$PATH $ export PATH=/usr/local/ActivePerl-5....
1
vote
1answer
20 views

How to prevent from destroying symlinks, using Perl when to replace with sed regex?

Based on How do I prevent sed -i from destroying symlinks?, but I use Perl. I tried by middle of all these questions: Is there a way to make perl -i not clobber symlinks? perl symlink on gz file How ...
1
vote
1answer
21 views

Disable Tomcat Session persistence using sed or perl

I need to disable Tomcat session persistence as I have implemented SpringSession on my Spring (not Spring Boot) Application. I've tried using sed and perl to edit multiple lines in the context.xml ...
1
vote
2answers
48 views

How to start a new column after every nth row?

I have a file (comma separated) on a Linux system with 3 columns. I want to start new column after every 4th row. Input: col1,col2,col3 1,disease1,high 1,disease2,low 1,disease3,high col1,col2,...
0
votes
1answer
16 views

Remove non-alphas while ignoring certain unicode chars

I have a text like the following: []përgjithshme [" është "] 28.748 [< kilometra katrorë.>] This text contains cyrillic characters in the range U400 - U4FF. I want to strip out the non-...
0
votes
0answers
36 views

Script can not write into dierectory

I have configured apache web server on fedora 29 , perl script that generates web page with current NIC information (state , speed , mac , etc.) and traffic graph. Script generates the web page and ...
0
votes
1answer
21 views

tracking segfault upon invocation of perl script (mytop tool and similar)

on my gentoo machine, mytop 1.9.1 quits upon invocation with the following output: # mytop Useless use of private variable in void context at /usr/bin/mytop line 1001. "my" variable $data masks ...
4
votes
3answers
351 views

Manipulating text in first column only? [duplicate]

Example Input: foobar@example.com foo@example.com,bar@example.com Example Output: foobar@example.org foo@example.com,bar@example.com So, in "normal" circumstances, it would obviously be easy to do ...
1
vote
5answers
86 views

Remove text between consecutive occurences of strings

I need to remove all text between two given strings in a text file. The strings may be located on different lines. For instance, in the following text file @article{ginsberg_lifespan_2018, title =...
0
votes
1answer
41 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
49 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
59 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
47 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: ...
0
votes
1answer
58 views

Print line and following text based on pattern matching

I am trying to filter lines from a text file based on patterns in proceeding lines which keeping the pattern matched line. I also need to rename the pattern matched files for example: >text chr1 ...
0
votes
1answer
38 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 ...
4
votes
3answers
296 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
211 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
1answer
43 views

Install custom perl modules

I have build an RPM from a proprietary software collection in a CentOS 7 environment but the build process required executing some Perl modules (.pm files) found within the source itself. When I ...
2
votes
0answers
33 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 ...
1
vote
1answer
41 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
3answers
65 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 ...
0
votes
1answer
44 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
1
vote
1answer
28 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
0answers
140 views

Perl v5.10.0 required--this is only v5.8.8, stopped at ./Configure line 12

when I try to configure new openssl package(openssl-1.1.1), I am getting that perl error.New openssl has dependency on perl version of 5.10.1. My build machine has two versions of perl -5.8.8 and 5.10....
0
votes
2answers
75 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
394 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?
0
votes
2answers
56 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:/...
-3
votes
3answers
124 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 ...
2
votes
3answers
189 views

Filtering list of numbers containing sequential digits

I would like to filter many text files. Each file contain a very long list of numbers. Filtering the files must occur by the number of the consecutive digits within each number. Example list form ...
6
votes
2answers
293 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
4answers
55 views

Apply if condition to all lines of a tab delim file which have same value in a particular column:

Basically I want to apply if condition in lines which have same value in column2. In example first three lines have same value in column2 (Disease1 ). Now for these three line I want to apply IF ...
-1
votes
1answer
47 views

Perl Script Output in Excel / Text file in Solaris 10

I have a perl script, I am not able to get output of script in an excel or text file format. Can someone please help me figure out that ? perl -MPOSIX -e ' opendir D, "." || die "open .: $!\n"; ...
0
votes
1answer
26 views

Random reading from file (perl)

In this section of code I need to read from file.txt randomly: ... open my $fh, '<', 'file.txt' or die $!; while ( <$fh> ) { next unless /\S/; chomp; my $response = $ua->get( "http://$_....
5
votes
4answers
357 views

Summing rows in a new column using sed, awk and perl?

I have a file that contain numbers something like: 1 11 323 2 13 3 3 44 4 4 66 23 5 70 23 6 34 23 7 24 22 8 27 5 How can I sum the rows and output the results in a column, so the results are as ...
0
votes
5answers
330 views

How do I delete all lines in a file until it matches a string line pattern? [duplicate]

How can I delete lines in a file until it matches a string line pattern? cat test.txt The first line The second line The third line The fourth line pen test/ut The sixth line The seventh line I ...
0
votes
3answers
77 views

Delete newline characters between patterns

foo I love Stack Exchange bar Some junk lines foo Welcome to the world of Bash bar foo Elon Musk rocks Yes, there is no bar complementing foo at the end of the file The required output is I love ...
0
votes
3answers
78 views

awk/perl print palindrome if not between brackets

I have a file with a bunch of strings, one on each line. I want to find and print a string only if it contains a palindrome and that palindrome is not between brackets. Examples: abba[cdef]gh # ...
-1
votes
3answers
126 views

remove the lines in CSV that contain specific pattern on the second field

How to remove the lines in .csv file that second field contain the word content? example : ams-hbase-log4j,content:\n#LicensedtotheApacheSoftwareFoundation(ASF)underone\n#...
2
votes
2answers
70 views

Default variables in Bash

The default variable for loops in Perl is $_. Is there any equivalent of this in Bash?
4
votes
1answer
325 views

BEGIN {…}; in Perl [closed]

I have a perl-script: #!/usr/bin/perl BEGIN { print "That's BEGIN message\n"; BEGIN { print "That's BEGIN-2 message\n"; }; END { print "That's END message\n"; }; BEGIN { print "That's ...
2
votes
3answers
59 views

How to remove Inverse match pairs?

I want to remove duplicate/inverse match pairs from a text file. E.g., the file contains data like the below: 10 |Name1 |20 |Name2 20 |Name2 |30 |Name3 20 |Name2 |10 |Name1 <-- Inverse pair (...
-1
votes
0answers
59 views

Apache limits maximum amount of Perl scripts running in the same time

I have a problem that Apache limits (or other setting effects it) limits the maximum amount of Perl Scripts running in the same time. Request goes through Nginx to Docker container with Apache and ...
0
votes
2answers
73 views

Compare lines in a file having common last column but different in another column

How to compare consecutive lines from a text file where last column should be same? And at least one value in the 2nd last column must be mismatched. Firstly, column 6 should be compared in the file, ...
6
votes
5answers
590 views

Replace a string before a certain line

I have one file like: ID_SOUR_CALENDAR BIGINT NOT NULL DEFAULT 0 COMPRESS 0 , UNIQUE PRIMARY INDEX ( CALENDAR_DATE ); ID , ID_SOUR , PRIMARY INDEX ( CALENDAR_DATE ); I want to replace the ',' by ')'...
1
vote
1answer
101 views

count all specific words that ended in each line

how to count all words that ended with ".wsp" in the file more file /application_1532998892988_0207/driver/BlockManager/memory/remainingOffHeapMem_MB.wsp /spark/application_1532998892988_0207/driver/...
1
vote
1answer
39 views

Skip text in output with grep in perl mode

I have text like this: blah, blah <foo:ImportantText> blah blah time=1.234 blah blah blah, blah <foo:AlsoImportant> blah blah blah time=9.9 blah blah blah, blah <foo:ImportantText> ...
0
votes
1answer
44 views

How to use sed to substitute everything else with another string except the pattern?

I need to use sed to replace everything before matching pattern with another string in a file There are various paths in my file. Last few components of those paths are the same irrespective of the ...
2
votes
1answer
81 views

Filenames with spaces inside perl command inside echo

How do I support filenames with spaces in the following command? echo "$(perl -MMIME::Base64 -e 'open F, shift; @lines=<F>; close F; print MIME::Base64::encode(join(q{}, @lines))' $filename)" ...