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
36 views

how to verify at least XG free space on /var

we have the following df -h output [root@trump var]# df -h | grep "/var" /dev/mapper/vg-lvm_var 101G 85G 17G 84% /var how to verify at least 10G free space on /var in bash/awk/perl one liner ...
1
vote
1answer
70 views

I can't print the default text in the Readline input

I am writing an interface to my database and would like to be able to edit entries. I thought I'd use Readline, but can't get it work. I'd say my code should work, based on Term::ReadLine::Gnu and ...
2
votes
2answers
94 views

Merge lists based upon duplicate values

I have sorted data like this: a a f b c c e d f z Essentially these lines are each lists of aliases for the same thing, and they need to be merged. This is simplified. In case it matters in the real ...
1
vote
2answers
225 views

sync password hashes of users UID>1000 between host A and B

I have two CentOS systems, I want to do syncing of password hashes (only) which are stored in /etc/shadow, from system A (local) to system B (remote) but only for these users which have UID > 1000 and ...
0
votes
3answers
633 views

perl oneliner - random string generator with non-alphanumeric [closed]

how to add non-alphanumeric characters to the map so it generates mix of alphanumeric and non-alphanumeric characters? $ for i in {1..5};do perl -le 'print map { (a..z,A..Z,0..9)[rand 62] } 0..pop' ...
0
votes
2answers
195 views

Match the nearest timestamp in milliseconds

I have a large data.txt file as below; for every timestamp, I need to find the nearest time match 5 minutes later and the value on column 4. Now print both in two new columns. for example for "2018-...
1
vote
2answers
61 views

Matching a pattern in Perl

I have a below input file which contains: 000ABCDEFGHIJKLMN2018022623595900021 CGT11~|~|110~|~|221~|~|H0331~|~|~|~| CGT11~|~|110~|~|222~|~|H0332~|~|~|~| CGT11~|~|110~|~|223~|~|H0335~|~|~|~| CGT11~|~|...
1
vote
1answer
711 views

Script cannot find Perl module, but module exists in local subdirectory

I'm running a Rasbian strecth 4.9.59-v7+ and I´m trying to run the following software https://github.com/weaknetlabs/warcarrier which looks really neat! When trying to run the script I receive the ...
0
votes
2answers
82 views

Remove lines of a file after the N firsts lines but before to integer number

I have a file like this: 1 2 3 4 5 0.05775 0.00238 0.02514 0.00469 0.01882 0.26868 0.04114 0.09359 0.02155 0.01367 0.11413 0.00907 0.04032 0.02487 ...
0
votes
3answers
117 views

what is the best way to match a version number from file

what is the best way to match specific version number ( or version number ) from file I did some options , but I think there are other best approach ( as perl one-liner ) version=23.092.12 cat ...
0
votes
1answer
218 views

log file check validation in Perl

I have "FDP_RecordLength_Error_02202018_020107.log" "FDP_HeaderOrTrailerRecord_Error_02202018_020107.log" "FDP_DetailRecord_Error_02202018_020107.log" and other log files as well. I want to check the ...
1
vote
1answer
35 views

Transposing Data - Easier Way to Add Additional Columns to Perl Script

I have a perl scrip below that does a fantastic job, however, I how want to perform the same task but on a larger file. The script below is designed for use on a file containing 15 columns, of which ...
0
votes
1answer
205 views

Cannot install URI::_foreign

Well I'm trying to install URI::_foreign on my server (I have root access) I get the following errors: CPAN: Storable loaded ok (v2.20) Going to read '/root/.cpan/Metadata' Database was generated on ...
-1
votes
3answers
127 views

awk perl copy first column in new lines

i use bash i have table like this 001_1_174 [g/n 474536 482492 mo[g/n 482492 504062 'er/ 504062 ...
4
votes
5answers
1k views

‌How to select rows with minimum value in each group based on first column as ID?

I have a file looks like this : 1 7.8e-12 1 7.8e-12 1 1.0e-11 2 9.3e-13 2 3.5e-12 2 3.5e-10 2 3.1e-9 3 3.0e-11 3 3.0e-11 3 1.7e-08 For every ...
2
votes
1answer
469 views

Log rotate using perl Logfile::Rotate

The below script works when executed on CentOS, but it doesn't rotate logs based on size. A new log is generated every time I execute this script. Can anyone tell me how to make this script work based ...
0
votes
1answer
40 views

How to remove a place holder in a text file with text from another file when multiple lines are present?

I have a file: - id: 1.4.25.2 name: 'Configuring a VNC Server' permalink: '/rhcsa/managing-network-services/configuring-vnc-access/configuring-a-vnc-server' description: '<*...
4
votes
3answers
2k views

What does '(…)? = $1 : $2' do in Perl?

I came across with these two lines, and though I've been trying to figure out what they do, I'm still in doubt about their meaning in the code. The piece of code I am talking about is: my $...
0
votes
3answers
96 views

AWK: search last column of INPUT.txt in TABLEs text and add correspond columns to INPUT.txt

dear all i have INPUT.txt like this (look at last column) INPUT.txt 63 M 27 BS/BA TEHRANI 3 4 298320 310050 11730 j j 63 M 27 BS/BA TEHRANI 3 4 310050 311430 1380 ( a 63 M 27 BS/BA TEHRANI 3 4 311430 ...
0
votes
0answers
151 views

zabbix template mysql (800+item)

I use this template. template-mysql-800-items when i send parameter by this command zabbix_sender -z zabbix -s db1 -k mysql[innodb_queries_inside] -o 100 -vv On zabbix server i can see result. ...
1
vote
1answer
90 views

Perl podusage generates man page with extra control-O's

I am using pod2usage in a Perl script to generate a man page. The code looks like this: use Pod::Usage; pod2usage(-verbose => 2) ; exit 0 ; ... some code ... __END__ ...
-1
votes
1answer
303 views

Split Large files based on line number, run it and then append the final output into one file

I am using an R package. The input files required to run in the the package are large(as big as 65 Gb of size) So I have decided to split the file in chunks based on line number and then merge the ...
0
votes
3answers
876 views

Get lines until first matched pattern range [duplicate]

I have a file that looks like as follows: line1 line2 line3 line4 line5 line6 line7 line5 line2 I want to get data between line1 and line5. I used awk '/line1/,/line5/' myfile. Expecting that output ...
0
votes
1answer
536 views

zabbix_sender error

What is the meaning of this error? [root@db2 zabbix]# zabbix_sender -z zabbix -s zabbix -k mysql[Threads_running] -o 100 -vv zabbix_sender [55944]: DEBUG: answer [{"response":"success",...
0
votes
1answer
702 views

Confused about using the Zabbix Template MySQL (800+ items)

Please explain the full use of this template.link template I searched very much on Google, I have configured as described but i can't use this yet. Can you fully explain? i have two centos 7. zabbix ...
0
votes
1answer
49 views

Invert last two subfolders of the directory structure

Basically, I request a unix way (bash, perl, etc) to invert the last two subfolders, like in this windows question: https://superuser.com/questions/221/how-can-i-invert-a-directory-structure This is ...
0
votes
1answer
105 views

Is it insecure to make Perl's prove command NOPASSWD in sudoers file?

I've got a Perl test script, initiated with prove, that tests a backup script that requires root privileges so rsync can change the permissions on the files it downloaded from a remote server. So I'...
0
votes
0answers
132 views

Safely granting permission to a Perl script to change users and groups of filed downloaded with rsync

I've got a Perl script which is a wrapper to a Net::OpenSSH object which I use to rsync a remote server's files to my local machine. I'm using the archive, -a, option to preserve file ownership and ...
1
vote
1answer
136 views

how to verify XML that include specific tags

is it possible to check by xmllint if xml include the follwing tags: Name uniq_String Version example of xml with three tags: <?xml version="1.0" encoding="UTF-8" ?> <!-- tasks ...
1
vote
1answer
80 views

cpanm vs apt upgrades

I'm updating my Perl modules. I've found this command elsewhere: cpan-outdated -p | cpanm I'm wondering if this won't bring in any conflicts with my Debian's apt-installed Perl modules. I had this ...
0
votes
7answers
79 views

capture the second field and the last field from string

we have files with the follwing file name format VER_{FILE NAME}_{VERSION} example VER_collect_important_info.pl_1.0.2 we want to capture only the "FILE NAME" and "VERSION" number so how to ...
4
votes
6answers
2k views

How to add lines/text to the beginning of a file

We have the following example file: tcpmux 1/tcp # TCP port service multiplexer tcpmux 1/udp # TCP port service multiplexer rje ...
1
vote
7answers
86 views

bash + how to verify all words in each line with the same count

how to verify that all words/strings in each line are with the same count if all words in each line with the same count then syntax will return true and number of counted word if lines are not with ...
1
vote
1answer
404 views

How to extract a line based on the multiple fields in perl

How to extract a line based on the multiple fields in perl I have below file: file1.txt and I want to extract line based on composite match of multiple fields meaning if the line has combination of ...
1
vote
4answers
125 views

bash + how to shift to the next string in list

The following list represented the tokens between sdb and sd$MAX (while MAX range could be c-z) For example: MAX=z list=$(eval echo sd{b..$MAX}) echo $list strings are: ( example ) sdb sdc sdd ...
0
votes
2answers
297 views

Extract part of the logs to other file

1) We have a process.log file in which we have lot of text data and in between we have some XML data published. 2) There of thousands of different XML published in the logs along with other text data. ...
2
votes
1answer
3k views

How to use grep command to search for multiple patterns in perl?

How to use grep command to search for multiple fields in perl? I have below file File1: access abc permit tcp sourceipaddress sourcesubnet destipaddr destsubnet eq portnumber Here I'm splitting ...
1
vote
2answers
62 views

Matching reversible pairs in a CSV file

I have a .csv file which looks like this: A,B,1999 C,D,1990 B,A,1989 D,A,1990 A,B,1999 ... I want to rearrange it to look roughly like this: A,B,1989,0,B,A,1 A,B,1999,2,B,A,0 C,D,1990,1,D,C,0 D,A,...
0
votes
1answer
2k views

How to extract XML data from logs using Unix shell script? [duplicate]

My question is not related to the Parse XML to get node value in bash script? Also i cannot install/use any new XML parser as per the company policy. This needs to be achieved using shell/perl/awk/...
1
vote
4answers
132 views

converting file in order to print only the hostname and IP

I need to convert the following file example 1 to the file as appears on example 2 so it will print machine name and IP but only in case "name" appears before host_name redhat03.rdns.com 10.10.29....
-4
votes
4answers
89 views

linux + re-order lines in file according to machine NUMBER

we have the following file more /home/list.in master01.fsdns.com AMBARI_METRICS STARTED master02.fsdns.com AMBARI_METRICS STARTED master03.fsdns.com AMBARI_METRICS STARTED ...
0
votes
3answers
161 views

how to find conflicts in fstab file

some times we noticed about conflicts in /etc/fstab file as the following example /dev/sdg appears twice ! /data/sdb appears twice ! # # /etc/fstab # Created by anaconda on Wed Nov 9 13:26:03 ...
0
votes
2answers
3k views

rsync command pass password though script

I am using following command rsync -avze ssh myUser@REMOTE_SERVER:/REMOTE_PATH/ LOCAL_PATH It's asking for password. Is it possible to pass password through any script? I do not want to use ssh ...
3
votes
9answers
300 views

Print line only if the upper line include specific word

We have the following file with hostnames and host ip's ( long file with 90-100 machines per linux machine ) hosts.cluster.conf "href" : "http://localhost:8080/api/v1/hosts/worker02.sys87.com", "...
1
vote
1answer
202 views

linux + how to match UUID in fstab file [duplicate]

I need to wrote the follwing task that will be part in my bash script we want to match all lines with UUID words in fstab file according to the following rules: UUID is in begging of file or ...
0
votes
3answers
4k views

Calculate Time difference between two lines

grep timestamp in a file as given below. Now I need to calculate time difference file data: 18:29:10 04:56:50 I tried following command its output is in minus: awk -F":" 'FNR==1{split($0,a,":");...
4
votes
3answers
708 views

how to find the last word in file & ignore empty spaces

how to find the last word in file even after word there are empty lines the case I tried this to find the last word tail -1 /tmp/requests.txt but no output I try the following approach awk '...
2
votes
1answer
192 views

Remove whitespace only between two characters { and } in file [duplicate]

I have file with json values : abc={"adf": "def", "abc2":"def2", "abc3" : "def3" } abc4= 1 abc = {hello : world, hello:"a"} I want to remove whitespace from everywhere in between { and } and not ...
1
vote
2answers
42 views

How to add an extra line that also have a pattern in file containing a pattern in previous line?

I have a file - something \title{\hypertarget{A64L}{A64L(3)}} something \title{\hypertarget{MALLOC}{MALLOC(3)}} something \title{\hypertarget{STRCMP}{STRCMP(3)}} The word in {} may be anything, ...
5
votes
5answers
532 views

bash + how to append path to the end of the line according to existing path

The following configuration file (example 1) isn't configured as it should be. Each line in file should contain the /grid/sdX (a to z) as described in example 2. I need to find a way to write a bash ...