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
0
votes
0answers
24 views

Getting error while running the shell script

CURRTIME=$(perl -e ' print time(), "\n"') FILETIME=$(cat timestamp.txt ) TIMEDIFF=$(($CURRTIME - $FILETIME)) I need to add 1 second to FILETIME variable, even if there is no entry in timestamp.txt, ...
0
votes
1answer
36 views

How does pcregrep works?

I have a file: This error -this -this -that [text I want] This error -asd -asfag -adsfhs [text I want] [text I want] This error -asdgsda -asdgg -gasdg I want to match to match except This error and ...
0
votes
1answer
49 views

bash + grep only the time stamp from output

we want to capture the time from the output and not the time from the command sshpass expected output Sun Jul 14 12:47:49 UTC 2019 Sun Jul 14 12:47:49 UTC 2019 Sun Jul 14 12:47:49 UTC 2019 but from ...
1
vote
2answers
21 views

Convert Excel file to PDF using Perl CGI

I'm trying to convert an xlsx file to pdf using Perl CGI (Mason). Since I did not find a way to convert a file using pure perl, I'm using soffice to perform the job. This works fine until I do it ...
0
votes
0answers
26 views

pssh + verify date between machines and alert if date difference is more then 3 second

we are using the following great pssh command in order to see if time differences is more then 3 second between machines pssh -i -o /tmp/out/ -e /tmp/err/ -H "master01 master02 master03 worker01 ...
13
votes
7answers
11k 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
vote
1answer
25 views

How to uninstall orphan Perl packages?

pacman this morning reported the following: WARNING: '/usr/lib/perl5/5.28' contains data from at least 4 packages which will NOT be used by the installed perl interpreter. -> Run the ...
0
votes
1answer
53 views

Perl regex matching apostrophe fails

I'm trying to write a Perl script to transform several sripts into a canonical form. I expected the script #!/usr/bin/perl -W use File::Spec; use Getopt::Long 2.3203 qw(:config auto_help auto_version)...
4
votes
2answers
3k views

Rebuild old Perl Modules

I just did a system update on Arch Linux (pacman -Syu) and saw a warning about there being old Perl modules: WARNING: '/usr/lib/perl5/site_perl' contains data from at least 2 packages which will NOT ...
0
votes
2answers
44 views

REGEX: flush a number of related chains in iptables

I want to flush a number of related chains in IPtables. Their names like 'f2b.*' I want the entire chain gone! e.g. all this gone. -A f2b-postfix-sasl -s 103.231.139.130/32 -j REJECT --reject-with ...
1
vote
1answer
36 views

Is this a good way to extract the name of a script?

My situation is this: I want a Perl script to say its own name. I tried print "$0\n"; which is a good solution if you are working in the same directory were the script is. I find this solution use ...
-2
votes
2answers
42 views

Perl::Find a substring and display a whole word

I have a text file that has some data like: PADHOGOA1 IOP055_VINREG5_1 ( .IO(VINREG5_1), .MONI(), .MON_D(px_IOP055_VINREG5_1_MON_D), .R0T(px_IOP054_VINREG5_0_R0T), .IO1() ); PADV30MA0 ...
3
votes
1answer
1k views

Modify filenames in Makefile

For reasons that are not important here, I have a source code that I process automatically file-by-file and the processed source files are renamed in a systematic manner. For example, I start out with ...
1
vote
3answers
104 views

Perl: Inserting at nth position in file

I have content in my file : 123456789 My output is: 1234CC789 Desired Output is: 1234CC56789 I am insert PP at nth position suppose. But when I am inserting any text it is inserting the text at ...
0
votes
1answer
25 views

Split and store in Perl

I have a file with this content: Ref BBPin r:/WORK/M375FS/HMLSBLK4BIT0P0_0/LSVCC15 Impl BBPin i:/WORK/M375FS/HMLSBLK4BIT0P0_0/LSVCC15 Ref BBPin r:/WORK/HMLSBLK4BIT0P0_0/LSVCC3 Impl ...
0
votes
1answer
295 views

Error trying to call find from perl

use warnings; use File::Find; my $srceDir = "//mnt/Share_Drive/Verizon PM&T/Capture Files/"; opendir(DIR, $srceDir) or die "Can't open $srceDir: $!"; my @files = (find -type f -newermt "12 Feb ...
1
vote
1answer
23 views

Convert XLS file to CSV file in perl without using spreadsheet [closed]

I have a file in .XLS format and I want to load that file on Informatica, for which I need to convert that file to .CSV, i.e. XLS to CSV.
1
vote
1answer
54 views

Escaping special characters &, $, ^, *, ! in unix command (bash perl)

Basically, I'm trying to send some email thru uucp to some especial accounts using the RFC 5322 standard that includes !#$%&'*+-/=?^_`{|}~; (https://en.wikipedia.org/wiki/Email_address#Local-part) ...
2
votes
1answer
1k views

SFTP Dual Factor Authentication

My Issue I am trying to automate a file fetch from an external [SFTP] server. The server is using 2-factor authentication. First, it needs a public-private key pairing established [This has already ...
0
votes
1answer
18 views

Extract pattern in perl

Is it possible to have just one regex which can extract the pattern "Mango-1.whatever.." in any of these 3 conditions (i.e. $dummy). I keep printing everything after this pattern. If I use comma in ...
0
votes
1answer
36 views

File read, compare and replace based on comparison in text file

Hi i need guidence to write code for file processing. i have one file which having ~ as delimeter and each line is keyword is 1st column. First i have to find the lines which matches with ^6999 Then ...
0
votes
2answers
48 views

How to Aggregate and get group count in specific column from text file by perl?

I have a big text file(with 15 lines) in this format (srip dip sport dport .....) I would like to group distinct first column and get the group counts, input file: 10.10.10.1 10.10.66.150 60761 502 ...
-1
votes
4answers
57 views

Compare 2 Files and Display Matched records

I really need your help Guys, I am new here in Unix. I want to compare my File2(3 column) to my File1(raw data), and save the result in a new file. But my files have a different delimiter. Example: ...
1
vote
2answers
140 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
2answers
70 views

Templated read (like scanf)

I've got a shell script variable, which currently is defined like this: tsource=/backup/%HOST%/%SHARE%/%PERIOD% I want to match this template to another variable, which might have a value like this: ...
0
votes
2answers
35 views

Returning wrong results in perl script [duplicate]

I am running this command on linux shell it works smoothly sed -i 's/\[-.*-]//g' error .txt What it does is it removes patterns like [-any text-] along with the brackets and - sign. but when I try ...
0
votes
3answers
85 views

perl regex - How to match foobar that does not begin with (\s*//\s*)

Basically I want to find foobar on uncommented lines like: // foobar # do not match me foobar # match me otherfoobar # do not match me To match the commented lines I use this: ^(\s*//...
1
vote
2answers
68 views

How to merge lines (of a multi-line code routine)

I have a file; contents are as follows: cat -n /tmp/my_file 1 verify(abc) { 2 foo : bar; 3 sub1(aa) { 4 line1; 5 } 6 sub2 (bb) { 7 line1; 8 // this line is a comment ...
2
votes
2answers
83 views

Use sed command for particular lines

I have a text file on a Linux machine and I want to run 3 sed commands for the lines entered by the user using a perl script. I am doing this manually till now. The sed commands I have to use are : ...
0
votes
2answers
92 views

How can I set up a local MTA on NixOS?

caff from nixpkgs.pgp-tools seems to require a local MTA to send keys with UIDs signed to the corresponding email addresses. (It uses perl's Mail::Mailer for that.) How can I set up a local MTA on my ...
0
votes
1answer
40 views

Getting Error with system() in perl

' Number found where operator expected at ./scripttemp.perl line 5, near ""sed -i -r "4" (Missing operator before 4?) String found where operator expected at ./scripttemp.perl line 5, near "}" ...
0
votes
2answers
62 views

Linux command to delete this

I want to delete this kind a pattern in my text file [-.(D_)-]. I did with sed and awk but no results. basically i want to delete anything that comes between [- & -] along with these characters ...
3
votes
3answers
398 views

How can I list the different hex characters between two files?

allHexChars.txt \x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\...
1
vote
2answers
33 views

Bash Perl multiline match into variable

I am trying to extract 2 strings from a multiline text. postmsg="\033[0;37m Email Settings" This line finds some match at the beginning of the string and puts it in a variable inCol. inCol=$(perl -...
0
votes
2answers
84 views

How to randomly change the order of two columns simultaneously for 1000 times using simulation values?

I have a data looks like this: ID pheno 231 0.12 432 0.32 11 0.0003 134 0.33 2334 0.553 12 0.33 100 0.331 1008 ...
1
vote
2answers
108 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
146 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
1answer
2k views

How to submit multiple commands as one liner in netbatch nbq commmand line

Can someone tell how to submit a one liner command using nbq command line? Submitted multiple commands in Linux works fine but not in nbq mode as below. find /nfs/disks/test_dir/ -name .snapshot -...
0
votes
0answers
25 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
54 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
47 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
111 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 ...
30
votes
10answers
55k 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
39 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 ...
8
votes
5answers
57k 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
17 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
54 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
72 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
47 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
91 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," ...