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

0
votes
4answers
40 views

Print only unique lines from file not the duplicates

I have a sorted words list, line by line file like so: apple apple grapes lime orange orange pear pear peach strawberry strawberry I only want to print out unique lines and drop duplicates: grapes ...
1
vote
1answer
40 views

How do you list number of lines of every file in a directory in human readable format.

I have a list of directories and subdirectories that contain large csv files. There are about 500 million lines in these files, each is a record. I would like to know How many lines are in each ...
0
votes
2answers
47 views

Need help in data arrangement

Could you please help me to sort this out, I have data which i would like get output in below format using shell/perl script. Data: Virtual Machine Test status Running. Assigned Server ...
1
vote
1answer
19 views

carton: command not found

Probably a simple question, I am trying to work with Perl for the first time and I am having some difficulty installing Carton. I am following this guide to install Erco. I am on Ubuntu 14. I have ...
0
votes
3answers
79 views

How to group a bunch of rows based on information from the first row?

I have a data file looks like : 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 . . . 1 0 4 4 3 1 2 0 0 0 3 1 1 2 1 1 1 1 1 1 0 1 1 3 . . . 0 0 0 0 0 0 0 3 3 1 1 2 3 2 1 2 2 3 1 2 3 1 2 2 . . . ...
0
votes
2answers
84 views

how to subtract first value from the last one within a column across a row in shell?

I have a data file looks like : 1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 3 3 2 4 5 8 9 10 13 17 19 29 30 32 33 50 700 800 900 950 first I want to insert space among each 3 identical values keeping each ...
0
votes
2answers
67 views

Script for ssh automatic login to a specific port

So currently, the "traditional" way to connect through SSH is the following one: ssh USERNAME@HOST -p PORT I would like to create a script in which I will include all the appropriate information ...
1
vote
1answer
26 views

Perl regex to recognize multiple strings

I have a file ~/foo.txt that has instances of each of the following strings alpha-1 alpha-2 alpha-3 alpha-4 alpha-5 alpha-6 alpha-7 alpha-8 alpha-9 I would like to replace each of these alpha-X ...
4
votes
4answers
123 views

Regular expression to replace an instance of two consecutive strings that might be separated by whitespace

I want to write a perl one-liner that replaces every instance of two specific consecutive strings that may or may not be separated by whitespace. For instance, say my two strings are john paul and ...
5
votes
2answers
143 views

Remove hyphenation with sed

I have a simple xml file containing some hyphenated words over page breaks. The input is something like ba bla bla hyphe-</page> <page>nated bla bla bla and the output should look ...
1
vote
1answer
23 views

How to Load data to one table from Multiple excel files?

I have to load data from multiple excel file into one table , Please help me to achieve the solution. We are getting excel file from different retail shop which contain multiple column , each file is ...
1
vote
4answers
324 views

Does “bash: command: command not found” return false?

I am writing a script to automate the configuration of software. I want to begin by checking to see if the script needs to install the software first, then configure it. If I was to check $ software ...
0
votes
2answers
48 views

perl: Replace string in file with double quotes

Following up question from http://unix.stackexchange.com/a/254637/18887 I have the following string in a bash variable This rule forbids throwing string literals or interpolations. While JavaScript ...
1
vote
3answers
52 views

Add extension to a list of files

I am trying to determine a perl method to add an extension to a list of files. I can already rename a list of files with a certain extension to some other extension, but I need to be able to do this ...
0
votes
1answer
22 views

DBD/DBI: Crashes if a program is forked

The below program works if the $crash parameter is not set: $ perl example mysql://:tange@/tange/mytable dburl mysql://:tange@/tange/mytable databasedriver mysql user password tange host port ...
3
votes
2answers
181 views

merge duplicate rows in columns

Given a file like this: x y y z x x x y z z y x x x z y y z z y x x x x x x x x I would like the output to be: x y+ z x x+ y z+ y x+ z y y z+ y x+ x+ Is that possible to do with awk or perl in a ...
4
votes
3answers
191 views

use line buffering when piping output to file

I have a perl program that prints to stdout, which I then pipe into a file, like this: ./skript.pl > file.txt 2>&1 This makes the output of that skript buffer. However, I would like to be ...
1
vote
1answer
38 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
26 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
39 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
51 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
34 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
47 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
28 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
195 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
93 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
60 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
198 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
62 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
33 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
217 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
87 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
76 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
50 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
42 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
116 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
46 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
62 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
49 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
92 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
20 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
46 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
80 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
132 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
50 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
82 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
630 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
47 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
34 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
337 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]) ; ...