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
1answer
1k views

how to print only Difference in two files using NR=FNR?

we have to print the old entries only Delta(Difference) in File-1 and File-2. newly added enties in files-1 no need to print. on my unix server everyday new report is extracted from system which is ...
3
votes
4answers
357 views

Extract specific characters from each line

I have a text file, and I want extract the string from each line coming after "OS=" input file line A0A0A9PBI3_ARUDO Uncharacterized protein OS=Arundo donax OX=35708 PE=4 SV=1 K3Y356_SETIT ATP-...
0
votes
2answers
175 views

Replace a command with the result (command output) in the line using sed

Is it possible to replace a command extracted by some regex with its output using sed? For example, I have the next file: 2 + 2 = $$shell:echo 2 + 2 | bc$$ // and "some unescaped text' here how I ...
0
votes
2answers
54 views

merge 1st column and 2nd column; 3rd and 4th column and so on with a separator

I have a text file with 61000 columns and 173 rows. I would like to merge data on every 2 columns i.e., columns 1 and 2 should be merged, 3 and 4 should be merged, 5 and 6 should be merged and so on. ...
4
votes
1answer
95 views

Printing PDF using Perl

I've got a script that creates a PDF and sends it to remote print server running CUPS. Using Net::Printer, I set up the printer: my $print_server = "remote_print.server"; my $printer ...
1
vote
2answers
31 views

Unable to use Perl join properly to append something to each occurrence - getting “Array found where operator expected at” error

I have log lines like these - /mnt/internal-app/logs/internal-app.log_2019-08-21.log.gz:2019-08-21 07:31:14,153 5458142 [XNIO-3 task-4] INFO c.c.p.i.m.ws.FileManger [FileName.java:1838] - UUIDs in ...
0
votes
1answer
907 views

Comparing two text files and printing out matching ids, sub_ids and timestamp related to the id

I found this solution in Perl interesting. I have a similar situation to print matching columns and two additional columns from the second file (Rev ID n date released). How do I read both files from ...
2
votes
1answer
49 views

compare columns from two different files and PRINT RECORDS FROM FIRST FILE those that DO NOT match from second file

I would like to compare columns from file one to two. Where column 2 of file1 should un-match from column 1 or 2 from file2 and print output from file 1. file1. cat test.head20.R2.fastq.tab @...
1
vote
3answers
25 views

insert strings/words to variable from file and join separator instead of space/s

We have the following file ( it is example ) more machines.txt Node23 Node34 Node12 Node95 Node23 We want to insert the list of all node to variable and join each node with “,” separator Example ...
3
votes
3answers
45 views

Rename to remove everything after a special character

I recently discovered the perl-based rename function but since I don't know anything about perl I can't use it properly. I found of a lot of question about the subject but nothing helped me. I would ...
-2
votes
4answers
8k views

how to check for disk in use on rhel

How to check if a disk is in use? If in use, How to check free, used space before I can start using it? I'm trying this in Perl and Any help is appreciated.
0
votes
1answer
48 views

Autostart pure-ftpd by running its Perl configuration file at the command line

I have manually built the pure-ftpd on my Raspberry Pi and it runs perfectly fine when I invoke /etc/pure-config.pl /etc/pure-ftpd.conf from the command line. I'd like to run that simple command /...
3
votes
7answers
714 views

Print only the last three columns from file

I have this file on Linux: 14:00:01.071 5255 604177 4 14:00:01.074 4608 1415742 14:00:01.074 18398 1122001 2 14:00:01.074 11723 155575 5 14:00:01.075 4695 885808 Desired Output: 14:00:01....
2
votes
2answers
6k views

Missing shell module in perl 5.18

I'm running Perl script under SLES 12 which has Perl 5.18 installed. When trying to run my Perl script I get an error: Can't locate Shell.pm in @INC (you may need to install the Shell module) (@INC ...
1
vote
0answers
41 views

Computing pair-wise time differences in mili seconds between matching records in a data table

I have a three-column table of data of the following form: TIME MPID CPID 14:00:04.909 10048 370007 14:00:05.320 10048 370007 14:00:05.462 10048 370008 14:00:05.761 10048 370008 14:00:...
1
vote
5answers
96 views

Editing a file in place using perl or awk

I have a large tab-delimited input file listed as below SF_0000000555_RDNAU_58_10293 10873 11041 + ID=match41;Target=SF_0000000005 99 267 168 SF_0000000555_RDNAU_58_10293 188079 ...
2
votes
2answers
63 views

Remove values from NUL separated file

I have an array of values v that I want to remove from the file f. f is NUL delimited. How do I proceed? I tried using sd, but it didn't work. Example: I have this file: # cat -v $attic ^@this is 1....
1
vote
2answers
1k views

How to delete a specifc pattern from a string using awk or perl?

How to delete only [gene=xyzI] pattern if I have multiple entries like this: >lcl|NZ_CP018664.1_gene_628 [gene=mscL] [locus_tag=AUO97_RS03160] [location=complement(694895..695326)] I want my ...
0
votes
1answer
51 views

Perl.cgi soap request HTTP ERROR 411

I'm trying to learn SoapUI, but when running the code below I'm getting HTTP ERROR 411 all files are in /var/www/html/ not sure what's the issue. #!/usr/bin/perl use SOAP::Transport::HTTP; SOAP::...
0
votes
2answers
54 views

How to extract a range of number from two files?

I'm trying to extract the number range from two files. $ cat file1.txt chr1 69509 chr1 69511 chr1 71000 chr1 358112 chr1 586874 chr1 744200 . . . $cat file2.txt chr1 69091 ...
0
votes
0answers
27 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
43 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
88 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
96 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
78 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 ...
14
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
117 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
92 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
4k 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
75 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
87 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
46 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 ...
1
vote
3answers
154 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
31 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
311 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
95 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
177 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) ...
0
votes
1answer
40 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
44 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
134 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
71 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
197 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
475 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
40 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
95 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
74 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
108 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
123 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
58 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
67 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 ...