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
1answer
22 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
38 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 ...
0
votes
1answer
669 views

AWStats on Debian Jessie Forbidden from Browser / Unresponsive from CLI

I asked this on SO a day or two ago and no response yet. Hoping for some insight here in getting AWStats configured and running on Debian Jessie. Installed AWStats with apt-get install awstats. No ...
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
0answers
18 views

Perl script doesn't execute even when executable permission given? [closed]

I have given a perl script file executable permission, but when I try to execute the file I get a "command not found" error. I have #!usr/local/bin/perl at the start of the script file.
8
votes
7answers
18k views

invalid SSL_version specified at /usr/share/perl5/IO/Socket/SSL.pm line 332

Since I upgraded my PC from (k)ubuntu 12.04 to 12.10 I receive this error message when trying to send an email using sendemail. Installing an older version of IO::Socket::SSL is not an option. I ...
0
votes
3answers
74 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
72 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 ...
1
vote
1answer
3k views

“Requires: perl(:MODULE_COMPAT_5.8.8)”

I use CentOS 6.5 for my server with below repository: IUS epel ces-standard-* base/upgrade/extras When I tried to update today (it's been a while I haven't updated this server), I got the ...
1
vote
1answer
24 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 ...
0
votes
2answers
64 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 ...
182
votes
5answers
371k views

How can I replace a string in a file(s)?

Replacing strings in files based on certain search criteria is a very common task. How can I replace string foo with bar in all files in the current directory? do the same recursively for sub ...
0
votes
2answers
2k views

Failed dependencies trying to install package 'libxml2'

I am trying to install libxml2, but my system complains about dependencies. The dependent packages exist on system. The ultimate goal is to install xml_grep2, I have been trying various methods ...
1
vote
2answers
92 views

how to replace a sed expression (change and print only matched line) with a perl expression?

I am trying to move to perl (from sed). But how can I replace this sed expression with perl in a similarly short way? sed -n '/patternmatch/s%stuff%changed%p' file I need to search for a pattern, ...
5
votes
2answers
141 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 ...
4
votes
4answers
121 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 ...
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
314 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
41 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 ...
4
votes
5answers
457 views

How to replace only the Nth occurrence of a pattern in a file?

How to replace the third occurrence of the string in the file using sed command. Example: Change only the third occurrence of is to us in the file. My input file contains: hai this is linux. hai ...
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
21 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
180 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 ...
0
votes
2answers
2k views

How to convert XML file to CSV using Perl?

I'm looking for some suggestion to convert the .asn1 (CDR Data) to CSV to load to tables. As per current approach I'm using informatica B2B parser to parse the ASN file to XML than using XSD loading ...
4
votes
3answers
190 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 ...
2
votes
1answer
86 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
2answers
1k views

How to “grep” for line length in a given range?

NOTE: This question is the complement of this Q&A: How to grep for lines shorter or longer than specific thresholds? I need to get only the lines from a textfile (a wordlist, separated with ...
-2
votes
1answer
38 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 ...
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 ...
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 ...
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
33 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 ...
5
votes
4answers
19k views

compare two columns of different files and print if it matches

I am using solaris 10 and Grep options involving -f doesnt work . I have two pipe separated files: file1: abc|123|BNY|apple| cab|234|cyx|orange| def|kumar|pki|bird| file 2 : abc|123| ...
0
votes
0answers
42 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 ...
6
votes
2answers
408 views

Execute a command within 'sed'

I have a list of random memory addresses saved in a text file, and I need to sed them out, decode them, and save them back to my file. However, the decoding operation I'm trying to perform is handled ...
2
votes
3answers
189 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 ...
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 ...
0
votes
1answer
57 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> ...
11
votes
7answers
11k views

How to insert the content of a file into another file before a pattern (marker)?

File1 contents: line1-file1 "1" line2-file1 "2" line3-file1 "3" line4-file1 "4" File2 contents: line1-file2 "25" line2-file2 "24" Pointer-file2 "23" ...
5
votes
3answers
61 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
31 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 ...
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 ...
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 ...
5
votes
2answers
2k views

Replace string with sequential index

Can someone suggest an elegant way to accomplish this? Input: test instant () test instant () ... test instant () //total 1000 lines output should be: test instant1 () test ...
4
votes
5answers
75 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 ...
2
votes
4answers
45 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 ...
0
votes
2answers
45 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 ...
4
votes
2answers
153 views

nix package manager: perl warning: Setting locale failed

Whenever I run a command for the nix package manager (e.g. nix-channel --update) I get the following warning: perl: warning: Setting locale failed. perl: warning: Please check that your locale ...