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 ...

learn more… | top users | synonyms

2
votes
3answers
205 views

How can I delete everything between two markers in a file?

I have a text in a text file, where I want everything that is between strings like \{{[} and {]}\} to be deleted - including these strings themselves. These two string can lie on different lines as ...
-1
votes
2answers
56 views

First match if we are on the first line of input, if so print the whole line, else print the first word followed by a comma

for eg: CREATE TABLE MWWDATA.ACK997 ( AKTYPE CHAR(2) DEFAULT '' NOT NULL , AKNUM CHAR(9) DEFAULT '' NOT NULL ); CREATE TABLE MWWDATA.APREIDEXC ( EMPLID NUMBER(15, 0) DEFAULT NULL ); ...
3
votes
2answers
95 views

How to search for the word stored in the hold space with sed?

This is a sed-specific question; I am well aware it could be done with other tools but I am working on expanding my knowledge of sed. How can I use sed to globally quote (actually backtick) a word ...
0
votes
1answer
2k views

automake error: Unescaped left brace in regex is deprecated

After compiling and installing GNU automake 1.15, I get this error whenever I run automake: Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- ...
2
votes
2answers
68 views

Compare three files based on columns using Perl

I have three files, and I need to match the first column of file 1 to the first column of file 2 and then match the second column of file 1 with the first column of file 3. file 1 contains the ...
1
vote
1answer
45 views

perl taint mode: Insecure dependency

ERROR: Insecure dependency in `` while running with -T switch at I am executing a bash script from perl script. my $date_tmp="31-DEC-2016"; my $new = `/bin/sh ./compareDate.sh "$date_tmp"`; I ...
3
votes
4answers
460 views

Executing a 'perl command' from shell and executing the same command from perl script using system command

I am not able to take care of special characters. I have the following perl script. while(@mapping_array[$i]) { chomp(@mapping_array[$i]); my @core= split ( / / , $mapping_array[$i]) ; @...
1
vote
3answers
45 views

Comparing across rows in Perl

I have a file: Name v1 v2 Type1 ABC 32 Type1 DEF 44 Type1 XXX 45 Type2 ABC 78 Type2 XXX 23 Type3 DEF 22 Type3 XXX 12 Type4 ABC 55 Type4 DEF 78 Type5 ABC 99 Type6 DEF 00 I'm trying to print ...
0
votes
2answers
24 views

perl: how to specific a alternative version?

I have two versions of perl: 5.10 and 5.8. 5.10 is at /usr/perl and 5.8 is at /opt/perl. When I launch a perl script, it searches for 5.10. Is it possible to use some variable to tell it to 5.8 ...
1
vote
1answer
47 views

stream editing tools: output what's scraped

I was just wondering if it was at all possible when using different stream editing and text processing/manipulation tools; such as grep, cut, sed, awk, perl etc. Are there ways to output (in the form ...
2
votes
4answers
153 views

Only leave longest line when first column is duplicate

INPUT: user@server:~/bar/foobar$ SAT=$(date -dsaturday +%Y-%m-%d); SUN=$(date -dsunday +%Y-%m-%d) user@server:~/bar/foobar$ awk 'BEGIN {FS="'^'"} {print $1"\t"$3"\t"$6}' STs.csv STt.csv | egrep -w "$...
0
votes
0answers
15 views

I want to merge CSV files to one Excel workbook in different sheets. I want each file in one sheet with the CSV file name as sheet name [duplicate]

input: 1-example.csv a b c 2-example.csv 1 2 3 output: output.csv/.xls sheet1-data(1-example.csv) sheet2-data(2-example.csv) a 1 b ...
2
votes
1answer
185 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 ...
1
vote
0answers
16 views

IRSSI notifier - by pulling method

Is there an option in irssi to get state about new unread private and public messages by external application. If there is such option, i could periodically read that info from my bash script and do ...
12
votes
6answers
6k views

How to delete the last column of a file in Linux

I want to delete the last column of a txt file, while I do not know what the column number is. How could I do this? Example: Input: 1223 1234 1323 ... 2222 123 1233 1234 1233 ... 3444 125 0000 5553 ...
-1
votes
2answers
54 views

how to run a command in many files by running the command only one time?

I would like to run following command on 31 separated file name chr1.txt ... chr31.txt , and get 31 outputs only by one run. this is command : cat input.txt | sed 's/.\{5\}/& /g' > output....
0
votes
0answers
156 views

Perl script to delete big directory

This blog gives different ways of deleting Big Directories and their relative times for deleting a directory with 500,000 files. The script using perl is reported to be fastest, which is given by cd ...
1
vote
2answers
61 views

How do I stream edit progress-like output?

I'm having trouble editing some progress output. In this case it's Postgres' pg_basebackup, but it's similar to other progress output like curl and wget. Take for example the output of this: ...
0
votes
4answers
326 views

How to sum up values of each two rows across their line in linux

I have a data like this: input.txt 1 0000100101000000 1 0000010100000000 2 1110000001000000 2 1111000000001000 3 0000000111111111 3 1111111100000000 4 8888345500000000 4 0000000000000000 and I ...
-1
votes
0answers
17 views

How to accumulate values of each two rows across a line in linux? [duplicate]

I have a data like this: 1 0000100101000000 1 0000010100000000 2 1110000001000000 2 1111000000001000 3 0000000111111111 3 1111111100000000 and I want to sum up the values within eachtwo rows with ...
0
votes
1answer
49 views

how to extract some rows in a data file by comparing with another data file? (merging) [duplicate]

I have 2 different file : first file: id1 19501112 id2 19831207 1d4 20001212 id6 20000101 id10 20061213 id11 20081212 id12 20100109 id13 20101218 id14 20101212 id15 20111111 id16 20150919 id20 ...
5
votes
4answers
314 views

how to split a file into separate files based on the column headers in original file?

I would like to split a file to different files based on the information in the first line. For example, I have: Input: 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 4 30 30 30 30 0 2 2 0 2 ...
4
votes
3answers
451 views

How to convert a single column file into a single row?

I would like to convert my one colum of many rows into one line: example : 1 1 1 1 1 2 2 2 3 3 4 and I want : 11111222334 any suggestion please?
1
vote
1answer
53 views

Specify a starting point for unix find and replace, then increment

I'm doing a renumbering of a reference attribute in an xml file. The attribute is, for example, data-seq="1". I can already renumber that attribute in all files by using this: find $DATA_PATH/content/...
0
votes
3answers
67 views

Null value than rename file

I have a shell to a task but I should handle the null value in this. So in the task i cut the part of a word and i delete or rename the file, but need another if element for null. For example: I ...
2
votes
1answer
83 views

Perl Error “Can't locate Thread/Pool/Simple.pm in @INC”

Can someone help me with this error? I've upgraded my MAC OS to Yosemite 10.10.5 and seeing this issue since. Can't locate Thread/Pool/Simple.pm in @INC (you may need to install the Thread::Pool::...
1
vote
1answer
64 views

Print attributes from two tags together

I am using XML:twig to extract some attributes from an XML file using Perl; Here is my code: use XML::Twig; my $file = $ARGV[0]; $file =~ /(.+)\.xml/; my $outfile = $1.".snp" ; open my $out,'>',$...
1
vote
1answer
32 views

conditional coloring using perl expression

I have two commands in perl and one test file test.txt: $ cat test.txt aaa bla bbb foo #ccc bar ddd 444 First perl expression colorizes any occurrence of aaa or bbb with red color: cat test.txt | ...
0
votes
3answers
87 views

Problems with a perl script that should remove strings in the lines of one file from another file

I have a file ~/foo and another file ~/remove.txt. I would like to write a perl script that loops over every line of ~/remove.txt and removes every instance of the string (<LINE>) from ~/foo (...
1
vote
3answers
120 views

Remove comma from columns in a file if it is at the end

I have a tab separated file contain 19 columns, some of these columns contain comma at the end. I want to removed these comma from all columns if it is at the end. Example: c1 c2 c3 c4 c5 ...
2
votes
2answers
328 views

alter a line and remove tag using perl from xml file?

I have an xml file (client_23.xml) in which I need to alter one line and remove one whole tag from it so I came up with perl script: In my xml file, I have a block like this. There will be only one ...
1
vote
2answers
320 views

Parse XML file to copy the content into another file at a particular spot in the file?

I have an xml file (client_23.xml) in which I need to add few lines at a particular section basis on what is there in other xml file (abc_lop.xml). Here is my abc_lop.xml file in which you see I have ...
10
votes
1answer
300 views

What's with all the renames?

On my Debian system (well, my LMDE system, but close enough), I have at least 3 different rename programs: /usr/local/bin/rename : This is a Perl script, written by Tom Christiansen. Oddly enough, I ...
2
votes
1answer
65 views

Meaning of this character class in perl?

I am new with PERL(though I have good background in reg-ex), I was going through one perl script and it has one characters class $alwayssep = "[\\?!()\";/\\|‘]"; Can anyone explain to me what is ...
0
votes
2answers
63 views

Taking numbers from a text file and add them together

I have text file with hundreds of lines like below. I am trying to find a way to pull the number of records and add them together. Then I want to put the answer in a separate file This is my first ...
1
vote
4answers
167 views

Replacing a “time” column with corresponding values

I have a file in the following format: "2004-04-19 12:25:57" 44 44 "2004-04-19 13:39:32" 36 36 "2004-04-19 14:00:53" 34 34 I need 2 new files: a) A file which will replace "time" values of the ...
1
vote
2answers
66 views

Execute Perl commands from a specific IP?

I have a Debian Jessie 8 server with three unique IPv4 IPs. I connect to the server from Windows 7 via Putty. I can open three Putty windows using each of the three IPs. I am trying to execute a Perl ...
1
vote
5answers
86 views

Making a *nicely* formatted list of number of files in directories - awk & sed probably

I have lots and lots of files in a series of directories, and would like a nicely formatted list of how many files are in each directory. The directories are ordered thus: Parent directories named A,...
2
votes
1answer
87 views

Why isn't rxvt-unicode launching with perl extensions enabled by default even though I built it with '--enable-perl' and even '--enable-everything'?

I'm trying to get 'clipboard' perl extension for urxvt to work. I installed the script, it didn't work, and after some searching around I discovered that Cygwin's rxvt-unicode package is built with "--...
1
vote
2answers
24 views

Perl script in bin that calls a file

I have a script ~/bin/script $ cat ~/bin/script #!/bin/bash perl -pe 's/loremipsum/`cat ~/foo/bar/file.txt`/ge' -i ~/path/to/target.txt The script is supposed to replace every instance of ...
1
vote
1answer
145 views

Script to remove certain span elements from an HTML file

I want to write a script that completely removes every instance of a particular span class from a given HTML file. For example, if my undesired span class is "foo" then running my script on the file ...
0
votes
1answer
51 views

Perl one-liner to replace a code block

I have a file foo.txt hello world first line to change second line to change I would like to write a perl one-liner that changes foo.txt to read hello world this is my ...
0
votes
2answers
41 views

Breaking up a file into two parts based on a particular line [duplicate]

I need to breakup a file into two separate files based on a particular line for example: . . sc_outfifo 0.000E+00 0.000E+00 0.000E+00 0.000E+00 1.586E-02 1.586E-02 1.586E-02 Fub_Level_DACGE(%) PS0_SI....
1
vote
2answers
2k views

perl library getopts.pl

I'm trying to install a program, but keeps giving an error saying it doesn't find the perl library getopts.pl. My perl version is v5.16.2. The error message is: Can't locate getopts.pl in @INC (@...
1
vote
2answers
383 views

Script that only counts Established, TIME_WAIT, and Closed Wait connections using Netstat

I'm trying to make a script (using Perl, but it isn't necessary) that will only count the number of Established, Time_Wait, and Closed_Wait connections on a system and print them in terminal. So far I'...
0
votes
1answer
669 views

Bash will not execute system command in Perl script

Need a Bash file to run a perl script. This is the Perl file. #!/usr/bin/perl -w use strict; system "fastacmd -s $Q -d $NewQuery -o ./gifiles/$Q.$NewQuery.txt"; I have left alot out to avoid ...
3
votes
0answers
91 views

apt-get upgrade with /usr/bin on aufs fails to create backup link [duplicate]

I'm trying to update a frugal persistent (root and home) install of antiX-15 x64 from stable to testing. I changed the source lists and ran apt-get update. apt-get upgrade then fails with the ...
1
vote
1answer
49 views

add pairwise values looking up from a file

I have several variables (col1) which have 3 values (col 3,4,5) for some levels (col2) mango123 L1 1 2 3 mango123 L2 4 5 6 squash378 L1 7 8 9 squash378 L5 10 12 13 squash378 L15 0 1 3 ...
1
vote
0answers
192 views

Daemonize a perl script at startup Linux

I have a custom version of CENTOS that I need to run a perl script as a daemon in at all times. To do this I want to get it to run on startup as a daemon. When the machine is on I can daemonize the ...
0
votes
2answers
3k views

How to detect and remove newline character within a column in a csv file?

I have a large (2 Million rows) csv file exported from a SQL Server database. I don't have access to the database, and there's some newline character within a column, which makes it difficult to ...