Stack Exchange Network

Stack Exchange network consists of 175 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.

1
vote
2answers
61 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
129 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
87 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
148 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
296 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
171 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
3k 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
607 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
168 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
509 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 ...
1
vote
2answers
768 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
2answers
123 views

conditional replacement of rows with a number

I have a big file containing 27 columns and nearly 6 million rows. The following is a little example of my file head data 0.65 0.722222 1.0 0.75 0 0.35 0.277778 0.0 0.25 0 0 ...
1
vote
6answers
151 views

how to capture specific strings from line

How to capture only the sdX from the following line using bash, awk, sed or perl in one liner command? echo ""dfs.datanode.data.dir" : "/rid/sdb/oo/hdfs/data,/rid/sdc/oo/hdfs/data,/rid/sdd/oo/hdfs/...
1
vote
1answer
42 views

Perl: is possible use variable substitution?

On bash I did #!/bin/bash DATE=`date +%m%y` echo $DATE on perl I try this one #!/usr/bin/perl $date=`date +%m%y`; print "date"; And give me..date string and not correct date.
1
vote
1answer
319 views

How to change empty xml tags in a file in unix

I have a XML file in unix server. I want to change a file like : all the empty tags have to be replaced like below example. This is just an example, file can have any number of empty tags with ...
4
votes
1answer
284 views

filter xml documents matching certains ids

Suppose you have a file containing many xml documents, like <a> <b> ... </a> in between xml documents there may be plain text log messages <x> ... </x> ... How ...
3
votes
1answer
64 views

Compare two files and retrieve corresponding results

I have two files.File1 contains 470.2843 organism AR_0036 123 Intermediate 470.2845 organism AR_0033 456 Susceptible 903909.3 organism Naval-83 789 Resistant and file2 contains ...
2
votes
1answer
61 views

compute sum up each 2 rows and replace them with another value if the sum is less than a specific value

I have a genotype matrix (with tabular space), with 2 million rows and 12 columns. Columns are individuals and rows are SNPs. I have 2 rows per each SNP for each individual, one is the number of ...
1
vote
2answers
275 views

How to extract specific pattern from a file in HP-UX

I would to like extract the pattern "/oracle" from a file. I tried with "grep -w" command but it returned all the lines which have oracle word. I need to extract only /oracle. Please tell me if any ...
-4
votes
1answer
51 views

Comparing two text files

I have a text file like this. 2XKJ;2XKK; B0V9T6 2XKJ;2XKK; B0VP98 3TSG; D3X610 and i have another file having PDB IDs. 2XKJ 2XKJ 2XKJ 2XKK I want a output like this 2XKJ B0V9T6 B0VP98 2XKJ ...
-2
votes
2answers
165 views

I have four files with 10 lines of each, how to get output like below

I have 4 files. I need to check that all the files have equal number of lines. If the numbers of lines differ, I need to detect this and output, for example: #file1 - 10 lines, file2 - 9 lines, ...
-1
votes
1answer
91 views

how append extra alias with some servers on particular words in authorization file in linux [closed]

In a authorization file having some defined servers of fields but they can differ from line to line. All I want to do is to add extra alias on particular field in that line. Need to add below extra ...
-2
votes
1answer
44 views

Remove the gap pattern from files [closed]

I want to remove gaps (-). if gap found continuous >10 in all >Tem at the same position then remove the all gaps and also remove the sequences or gap from the query at the same position which are in ...
1
vote
2answers
111 views

intersection beween 2 files (values in file 1 which fall in range of values in file 2)

I have a file named snp_data containing SNP (Single-Nucleotide Polymorphism) chromosome data. This is a 3-column, white-space delimited CSV file which has the following format: user@host:~$ cat ...
1
vote
1answer
281 views

assign uniq identifier or serial number to duplicate or uinq values based on any column

i have input file like this which have duplicates values, i want to give uniq identifier for each uniq value based on first column (col1) mins duplicate rows have same identifier before decimal point ...
2
votes
2answers
74 views

Perl script giving different output on bash shell in Linux and /sbin/sh shell on HP unix

Input: tmp# cat test5 1234 012345 0.000 01234 01/02/03 5467 01234 0123 05554567 234 0099 0000 000054 Output on Bash Shell: [tmp]# perl -lpe 's#(^|...
0
votes
1answer
2k views

Unable to update ubuntu 16

After executing apt-get update iam unable to install any packages. # dpkg --configure -a dpkg: dependency problems prevent configuration of libperl5.22:amd64: libperl5.22:amd64 depends on perl-...
4
votes
1answer
86 views

Does Debian have a Perl style guide?

I'm going to be writing some heavy patches for Debian perl utilities. I have a lot of experience doing this. Some of their methods are really antiquated, like bareword file handles.. Is there a style ...
2
votes
1answer
91 views

replacing values in one with the values in another file

I have a csv file named eche in following format: INCON,--,INITIAL,CONDITIONS,FOR*****,ELEMENTS,AT,TIME ,0.315570E+13 VC76,0.10000000E+00,0.2837726135782E+08,0.6756896308414E+02 1K02,0.10000000E+00,0....
-1
votes
2answers
101 views

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

I have a three-column table of data of the following form: TIME MPID CPID 16:45:51 10051 77845 16:45:51 10051 77845 16:46:52 10051 77846 16:46:53 10051 77846 16:48:38 ...
1
vote
2answers
7k views

sh: 1: program not found

I have written a script to execute files one by one by calling a installed program. The same program is executing from terminal, like procheck abc.pdb, then it's working fine. But when I execute this ...
2
votes
1answer
740 views

passing a named variable as a command line argument to a perl script

awk offers a convenient way to pass named variables to a script using the -v flag (e.g., awk -v var="value" ...), a facility that is quite useful when composing ad hoc scripts. Can the same be done ...
2
votes
2answers
1k views

sendmail with html and file content

I need to send contents of a file in an email and add some html note at the beginning and ending of the file. I have used "sendmail" for the purpose, however when I receive the email I do not see the ...
1
vote
2answers
3k views

sed + replace only the second match word

we have the following file: more /tmp/file Allow,Deny Allow,Deny we want to change only the second match word ( to replace Allow,Deny with Deny,Allow ) so we did sed 's/Allow,Deny/Deny,Allow/1' /...
0
votes
1answer
78 views

How to remove overlapping regions in gff3 file using perl?

I am trying to remove overlapping regions from a 9 column gff3 file. **Input file:** scaffold591 Source gene 3322458 3376057 0.41 - . ID=g24007 scaffold591 Source transcript 3322458 3376057 0.41 - . ...
1
vote
1answer
95 views

pairwise combination of string based on two columns

I am trying to obtain the pairwise combination of of string available for each stack of data, input file contains two columns: col1 is genenames, col2 is name of various stressors. gene1 ...
2
votes
1answer
294 views

how to divide values in each row by the sum up values of two rows (translate bash to perl or python)

I have a population allele count data, looks like this 1 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 4 0 2 0 0 0 0 0 0 ...
-1
votes
1answer
128 views

How to extract data from gff3 file using Ids from another file?

I have a file that contains several IDs File 1: g24007 g51692 And a gff3 file as follows File2: # start gene g24007 scaffold591 method gene 3322458 3376057 0.41 - . ID=g24007 ...
4
votes
1answer
5k views

Run sed command in perl script

I am unable to invoke the sed command from the perl script as below: #!/usr/bin/perl my $cmd = ('sed 's/...........//;s/............$//' a_file.txt >> a_newfile.txt'); system($cmd); Below ...
1
vote
1answer
46 views

sed + remove the “#” character in case line appears

we have the following file: cat graphite-web.conf #<IfModule mod_authz_core.c> # # Apache 2.4 # Require local # Order Allow,Deny # Allow from All # Require ...
0
votes
1answer
57 views

Perl: Error code returned to open3 after killed program

This program shows which error is returned to open3 when running either sleep 3 or true;sleep 3 and sleep is killed: #!/bin/bash ...
0
votes
2answers
347 views

Print file line-by-line, but handle the file changing mid-execution

The following bash command reads the input file then prints each line with a 15 second pause between them: IFS=$'\n';for line in $(cat file.txt | tail -n +2); do echo $line && sleep 15; done; ...
0
votes
1answer
110 views

Search pattern in a file and replace substring in the column inline

Below is extract from the file to be changed: May use awk or sed...any utility is good for pattern matching. rhts-mgr hostname g05-rhts01 rhts-mgr ntp-server-ip-addr ...
-1
votes
3answers
132 views

How do I replace [ with \[ on matching lines?

How can I replace [ with \[ in multiple lines, where there may be multiple occurrences per line, but only do it on lines that start with ABCD?
1
vote
1answer
154 views

Install program with Perl?

I'm trying to install GTK YouTube Viewer from GitHub (https://github.com/trizen/youtube-viewer) in Q4OS (Debian-based). I downloaded the .zip file and extracted it, then tried to run the first ...
0
votes
0answers
107 views

Removing lines from file matching 2 strings

I am trying to remove lines in a file that contain 2 strings. I am using: perl -i.tmp -ne "print unless /$STRING_A/ and /$STRING_B/" /foo/bar/file.txt The result is that all lines from the file ...
1
vote
1answer
82 views

Help with oneliner - create random files, rename to two-char filename, fill with random strings [closed]

Would anyone be so kind and point me on how to make an one-liner from this? Or maybe use sed/awk/xargs? Or Perl? Or just make it simpler I have achieved this by searching stackexchange and editing ...