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
2
votes
1answer
85 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
161 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
45 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
53 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
470 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
128 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
2k 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
66 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
154 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
247 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
863 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
57 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
55 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
31 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
412 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 ...
1
vote
5answers
1k 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 ...
1
vote
3answers
105 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
145 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
248 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
74 views

Default variables in Bash

The default variable for loops in Perl is $_. Is there any equivalent of this in Bash?
4
votes
1answer
367 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
68 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 (...
0
votes
2answers
168 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
931 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
103 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
60 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
47 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 ...
3
votes
1answer
95 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)" ...
1
vote
1answer
42 views

perl symlink on gz file

I have a file file1.txt.gz and I am trying to create a symlink to a regular file as below using perl symlink ("file1.txt.gz", orig_file1); But this doesnt seem to work unless I add .gz suffix to the ...
1
vote
2answers
108 views

perl + ignore lines with remarks and delete duplicate lines with match word [closed]

We create the following Perl one liner. In order to delete double lines except the first match line, the second part of the syntax is to ignore the lines with remark "#". Example: # more /tmp/test ...
1
vote
1answer
128 views

Equivalent of “ssh-keyscan -H” in Solaris 10/11

I'm creating a Perl program that adds the specified host in root's known_hosts file. The program works in AIX and Linux, but not in Solaris and sadly, I can't find its equivalent command. Sample line:...
2
votes
3answers
72 views

how to remove syntax with uniq characters from line

we have the following configuration file, env.gc.txt export SERVER_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:{{hbase_log_dir}}/gc.log-`date +'%Y%m%d%H%M'`" We try to ...
3
votes
2answers
94 views

How to add properties in the end of the two first lines with double quote?

We want to add the following properties: -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M in the two first lines that contain the word - HBASE_MASTER_OPTS Example before ...
0
votes
3answers
372 views

Delete the oldest files in folder if combined size of folder is more than 10G

The following syntax will remove the files under hive folder: /usr/bin/find /var/log/hive -type f -print -delete I am trying to do the following: Remove the oldest files under /var/log/hive only if ...
-1
votes
1answer
40 views

How to delete from configuration file variable that not equal to 100

How to delete from configuration file the variable/s hadoop.tasklog.totalLogFileSize that are not equal to 100 example more file.conf hadoop.tasklog.totalLogFileSize=107 hadoop.tasklog....
3
votes
5answers
919 views

Insert multiline text before the first matching line in a file

we want to add the following lines in log4j file log4j.appender.DRFA=org.apache.log4j.RollingFileAppender log4j.appender.DRFA.MaxBackupIndex=100 log4j.appender.DRFA.MaxFileSize=10MB but these lines ...
-1
votes
2answers
76 views

sed + mark line in case of marched word

we want to mark with "#" the matched line by sed or perl line liner for example we want to mark all lines in file that include the DatePattern word log4j.appender.DRFA.DatePattern=.yyyy-MM-dd ...
-1
votes
5answers
315 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} ...
2
votes
2answers
70 views

Finding Greek from the command-line

How can I use perl on the command-line to print only lines containing Greek unicode characters? For example, only the second of the following lines hullo, world χαῖρε, ὦ κόσμε It should be ...
1
vote
2answers
64 views

change 3rd character in a line

input: dummy - 22847847 sha - 84734747 DHS - 374874 expected output: du1my - 22847847 sh1 - 84734747 DH1 - 374874
1
vote
3answers
736 views

Delete a part of a line with sed?

I have the next output: Date Time: June 22 12:40:00 Product User Host IP Software User User *.***.***.*** Software1 User User *.***.***.*** I tried some functions with sed and awk, but is not ...
2
votes
1answer
85 views

AWK | Dynamic row to column conversion

My Files: EventTime=20180726001317 ObjectOfReference=TCU_XXX202 SPtext=Heartbeat Failure EAName=TCU_XXX202 EventTime=20180726001317 ObjectOfReference=TCU_XXX203 SPtext=Heartbeat Failure EAName=...
1
vote
2answers
180 views

Getting a row data from matching column in CSV file in Perl?

I am not able to attach the CSV file, so I have attached the images so that the content is clear. I used awk and perl one liners but that is not giving any output. Please help me know, how can I get ...
0
votes
3answers
225 views

Have two lists, want to exclude list2 from list1

List1: 1,name1 2,name2 3,name3 4,name4 5,name5 6,name6 7,name7 ...
1
vote
4answers
69 views

Search and replace using a custom utility

I want to run a utility for replace values matching a regular expression. This means for every match of a regular expression, call the utility with the characters comprising the match. The output of ...
-2
votes
2answers
505 views

how insert column of same number in text file?

I have input file like::: a.txt 1 0.4 0.8 2 0.5 3.0 5 0.8 3.5 I want output like this::: 1.txt 1 3 0.4 0.8 2 3 0.5 3.0 5 3 0.8 3.5 1 8 0.4 0.8 2 8 0.5 3.0 5 8 0.8 3.5 I want to add same number ...
3
votes
1answer
339 views

Remove multiple strings from file on command line, high performance [closed]

Is there an elegant, high-performance one-liner way to remove multiple complete strings from an input? I process large text files, e.g., 1 million lines in inputfile, and 100k matching strings in ...
0
votes
1answer
78 views

grep + search recursive complex syntax under folder in files/scripts

We want to search the following line recursive under folder/s awk '{print}'|grep -i -e 'port is up' -e 'valid output' so we did that: grep -r "awk '{print}'|grep -i -e 'port is up' -e 'valid output'...
-2
votes
1answer
50 views

replace name after specific syntax

We have Bash script. We want to change the name - master02 with $machine_master in the Bash script. value=master02_up #master02 http://master02.$domain:8080 How to change master02 to $...
0
votes
1answer
137 views

Why doesn't rpm or dnf recognize default perl?

I have an rpm package I built which depends on perl. When I try to install this package it fails: $ rpm -ivh <package-y> error: Failed dependencies: perl is needed by package-y.x86_64 If I ...