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

1
vote
1answer
39 views

Perl - Why I can't use a variable into regex?

I'm sorry not being too specific in the title but I couldn't get it more specific than that. Why can't I use if($l =~ $ARGV[0]) but I can use if($l =~ /$ARGV[0]/g? first case $ perl script.pl ...
1
vote
1answer
28 views

Why isn't this perl regex capturing the backreference?

I have a directory of files $ ls -1 ep2.mp4 ep3.mp4 ep4.mp4 ep5.mp4 ep6.mp4 ep7.mp4 I want to use the perl rename utility to make all files look like e.g. ep02.mp4 Command I am using rename -n ...
-2
votes
1answer
62 views

Jobs not working in cron, but working manually

I have gone through similar posts in this website, but none of them is matching my query. I have the below content in my crontab, but it is not working. * * * * * perl sc.pl And when i'm trying ...
0
votes
2answers
52 views

Parsing a Blocked file and generating smaller files

I have a file like below: 1weather dnsndjsdn 2nm bdbdb bdbdbdbdnnd 3gfdu hsihdishdis 5 1hdohdsohsoihssodhoishs 2nfdksnkdsnfsdsjndkdj 3kjdscdskndskjndndsdsdsd 5 Like wise I might have close to ...
1
vote
3answers
86 views

Bash - Perl Script variable insertion

I'm having some troubles trying to insert a bash variable inside my perl code. The purpose of the code is to execute a certain perl printing command into a terminal using a bash script file. I have ...
0
votes
0answers
64 views

Squid proxy not running URL rewrite program?

I'm running Squid3 on a Raspberry Pi according to the setup for Upside-Down-Ternet (https://help.ubuntu.com/community/Upside-Down-TernetHowTo) to create a proxy that alters images. Eventually, I'll ...
0
votes
1answer
32 views

Take output of array, and put into new array (perl script)

I have an array set up to check different workstations to see if any logs are present, and if logs are present, to delete them. The problem is, every time I execute the script, it has to crawl through ...
2
votes
3answers
241 views

Can I use the find command to pass arguments to perl?

I have a perl script $ cat ~/script.pl sub main { my ($file) = @_; <STUFF> } } foreach (@ARGV) { main($_); } I want to execute ~/script.pl on every .txt file under the ...
1
vote
3answers
102 views

How to adjust the spacing between characters following a specific string?

I have a large file ~/foo.txt. Thousands of lines of the form SIZE : X Y are scattered throughout the file where X and Y are integers. My problem is that sometimes the integers X and Y are ...
0
votes
1answer
65 views

How can I make a perl script parse blocks more intelligently?

I have a file ~/bigfile.txt that consists of thousands of blocks of text of the form BLOCK NUMBER : <block> SIZE : <size1> <size2> EXTRA : <extraNumber> <block of text> ...
4
votes
5answers
239 views

Print several lines after nth occurence in bash

I'm looking for a way to search for the nth occurrence of a pattern and print k lines after the pattern. I guess awk would work better than grep in this case but I cannot figure out the way to do it ...
5
votes
3answers
64 views

Combine information from two files, line by line

I have 2 files as input: File 1 (space separated) ID POS a0 a1 SNP1 123 A C SNP2 456 T C SNP3 789 G A File 2 (space separated) 0 1 0 1 0 0 0 1 1 1 0 0 1 0 0 1 0 1 1 1 0 0 0 1 Required output A ...
2
votes
1answer
38 views

To Apply Answers to MCQs

I am now extending my own answers to MCQs, as made How to SED these paragraphs to MCQ format?. Data in file.txt 1 c 2 a Data in exam.tex \item Which of the following lorem ipsun are the best ...
5
votes
5answers
227 views

How to SED these paragraphs to MCQ format?

My data: Question Nr. 311 Main proteins are in the lorem ipsun A Lorem RNA test B Cells C Metoclom D Cells E Muscles Question Nr. 312 Main proteins are in the lorem ipsun A Lorem B Cells C ...
2
votes
1answer
97 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 ...
4
votes
5answers
91 views

Count unique associated values in awk (or perl)

I've already found "How to print incremental count of occurrences of unique values in column 1", which is similar to my question, but the answer isn't sufficient for my purposes. First let me just ...
0
votes
2answers
83 views

Apache 2.4.10 page not displayed

I'm not a big expert in Apache and I facing with a particular problem. I have 2 server where in the first I run Debian 7.9 with Apache/2.2.22, in the other one I have Debian Apache/2.4.10. In both ...
2
votes
2answers
57 views

How to escape metacharacters for egrep like metaquote from Perl?

Perl has a function called metaquote() to escape all special characters for a regular expression. Is there an equivalent technique for egrep? Example: If I am searching for the string abc.def.ghi, I ...
0
votes
1answer
166 views

Fedora 23: “Unescaped left brace is deprecated” error in LaTeX

After updating from Fedora 22 to Fedora 23, I'm having trouble compiling anything with biblatex (biber as backend). Anything without biblatex compiles just fine, so I'm assuming it's something with ...
0
votes
1answer
52 views

ssed -R versus perl -pe

If you want a sed with perl-style regular expressions, it seems that there are two ways to do it: ssed -R perl -pe Is there any reason to prefer one tool over the other for this purpose? They both ...
1
vote
1answer
65 views

expand data based on scores

Firstly I have a set of valid combinations of 3 columns (validlist), so the final result must be a subset of this file. a b c c b c p b d d y d p y d x y z I have a score ...
2
votes
2answers
72 views

Replacing matching text after two matching lines

I have a YAML file which includes a stanza looks this: admin::common::passwords: alice: password: '$6$oTQhLvN/4VFJPscD$8LYwUMSFi' bob: password: '$6$JKOtLF0wHeZfIskt$W/M5.ugDS' If the ...
1
vote
2answers
124 views

Why is a2p (Awk to Perl translator) installed by default? Why would I want to convert Awk to Perl? [closed]

I am surprised to see the a2p utility installed by default in my Linux distribution. a2p is a command line utility that converts an Awk program from standard input to a perl program that it outputs ...
1
vote
2answers
23 views

get command line perl command to report what changes it's made

I am using the following command (on Solaris) to remove the protocol from a bunch of files. find . -name "*.txt" -exec perl -pi -e 's/http//g' '{}' \; Is there a way to have a verbose output so ...
2
votes
4answers
49 views

How to append a line that does not start with '<' to the previous line

I have a log which contains XML lines. Sample format below: <head> <body> <line> asdasd</line> </body> </head> I want to scan the log file and ...
4
votes
2answers
103 views

Why doesn't my Perl play nice with Unicode?

On my new Arch installation, perl doesn't seem to play nice with Unicode. For example, given this input file: ελα ρε 王小红 This command should give me the last two characters of each line: $ perl ...
2
votes
3answers
169 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
54 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
94 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
65 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
41 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"`; ...
3
votes
4answers
414 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
44 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
23 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
45 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
151 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
168 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
4k 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
52 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' > ...
0
votes
0answers
121 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
58 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
299 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
16 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
42 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
291 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
387 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
47 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 ...