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.

Filter by
Sorted by
Tagged with
0
votes
1answer
411 views

perl(Inline) module is needed

I decided to view the contents of buffers cache using the tool called fincore while trying to install I have been getting the error as warning: fincore-1.9-1.el6.rf.x86_64.rpm: Header V3 DSA/SHA1 ...
2
votes
4answers
1k views

Take a sum based upon particular columns

I have a huge pile of data—around 30 to 40 Million data items. We need to process these files and send to another interface team. Below is my file format which we receive c1 c2 c3 c4 c5 ...
1
vote
1answer
82 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 ...
1
vote
1answer
332 views

awk script to rearrange similar rows

I want rearrange about 5 million rows (with 300 columns) into groups. Data looks like the following: where there were various experiments (column 2) conducted at different locations (column headers ...
2
votes
1answer
1k views

How to filter an array of strings in ksh

I want to remove the IP's as defined in "bb" array from "aa" array so the IP's 255.0.0.0 and 255.255.255.0 will be removed from the list in aa array. When I run my ksh code and later print the array ...
0
votes
1answer
100 views

grep + search recursive complex syntax under folder in files/scripts

We want to search the following line recursive under folder/s awk '{print}'|grep -i -e 'port is up' -e 'valid output' so we did that: grep -r "awk '{print}'|grep -i -e 'port is up' -e 'valid output'...
1
vote
1answer
51 views

perl + uniq characters before variable

What is the meaning of the characters "%%" before the variable EOF ? $LINE =`tail -1 $FILE `; chomp($LINE); if ($LINE eq "%%EOF") { . . .
0
votes
5answers
1k views

df -k + how to match the root volume line

How to match the "/" volume from df -k command? I tried the following: [root@machine /]# df -k | grep "/" /dev/vx/dsk/bootdg/rootvol 130926685 71378710 58238709 56% / /devices ...
2
votes
3answers
526 views

Get row data for non-matching column values

I want to read the file (1600 rows) and get rows only the columns have different values (sno1, sno2, sno3 & sno4-should be not be equal value) and it should be above 50%.The example of output ...
7
votes
3answers
935 views

sum all numbers from “du”

We want to calculate the first numbers that we get from du du -b /tmp/* 6 /tmp/216c6f99-6671-4865-b8bc-7205f5388752_resources 668669 /tmp/hadoop7887078727316788325.tmp 6 /tmp/hadoop-hdfs ...
0
votes
0answers
122 views

Compare two log files line by line and print difference

I have to compare two different log files line by line (in each line data between two symbols (: and ;) is to be checked) and print all lines of log 1 that are not in log 2. If two or more lines have ...
4
votes
0answers
2k views

perl: warning: Setting locale failed

I bought a VPS, Centos 7. However, I was able to understand what was going on with SSH and connected to my WHM. After connecting, I get a list of errors and there is something like this: perl: ...
1
vote
1answer
211 views

Unix perl match string and delete line

Im using perl to remove a string from a file, it is removing the string from file, But the actual line is not getting deleted, Due to which the next insert to the files are getting written over next ...
0
votes
1answer
43 views

Looping 'find…-type f': Getting filenames by dir/subdir, ouputing a txt with name dir_subdir_fname.txt

My data structure is something like: dir1/subdir1_level1/subdir1_level2.../subdir1_leveln dir1/subdir2_level1/subdir2_level2.../subdir2_leveln ... Which means that the levels I'm working with are ...
28
votes
4answers
8k views

Why is Perl installed by default with most Linux distributions?

Why is Perl installed by default with most Linux distributions?
1
vote
2answers
104 views

How can I extract only the pid column and only the pathname column in the lsof output?

$ sudo lsof -u t | grep -i "\.pdf" evince 1788 t 37r REG 8,4 176328 134478 /home/t/some/path1/white space/string1 + string2 string3.pdf evince 3737 t 36r ...
3
votes
4answers
2k views

Match a pattern and replace the first instance of string following it

I'm scripting the modification of a config file laid out like this: [purple] auth = no enabled = 0 username = password = priority = 0 host = True [shovel] group = manual = False enabled = 0 ...
2
votes
1answer
324 views

Perl run command on remote system

I need to run a series of commands on remote systems, but am having problems with perl staying logged in. I "can't" use the ssh or telnet command, as it is a service account logging in and has no ...
4
votes
3answers
6k views

Replacing string in all files found by grep. Can't get it to work

I find all needed files with grep: grep --include=\*.{php,ini,conf,sh} -ril -P "'([\d\w\-\_\.]+)(@domain.com)'" '/var/www_data/somepath/' Now I assume it's either use of sed or perl to for ...
0
votes
5answers
170 views

How to replace new line \n and upcoming + sign with space

Replace new line \n and upcoming + sign with space input file ABC + DEF foo + bar Output should be ABC DEF foo bar
0
votes
1answer
142 views

Join two tables based on non-sharing values in chosen column

I have been using "Perl for biologists with little computer coding knowledge" from site called Scriptome (Harvard). It gives great Perl one-liners to achieve desired functions which runs on Unix ...
5
votes
4answers
2k views

concatenate lines based on first char of next line

I am looking for away contact lines based on the next line. So far the only way I see is to create a shell script that will read line by line and will do something along these lines: while read line ...
36
votes
9answers
23k views

How can you combine all lines that end with a backslash character?

Using a common command line tool like sed or awk, is it possible to join all lines that end with a given character, like a backslash? For example, given the file: foo bar \ bash \ baz dude \ happy ...
2
votes
1answer
189 views

Why can't I pass a regex in @ARGV on the command line?

Why can't I use if($l =~ $ARGV[0]) but I can use if($l =~ /$ARGV[0]/g? first case $ perl script.pl '/^[\w]/g' second case $ perl script.pl '^[\w]'
38
votes
7answers
5k views

Linux equivalent to PowerShell's “one-to-many” remoting

Coming from Windows administration, I want to dig deeper in Linux (Debian). One of my burning questions I could not answer searching the web (didn't find it) is: how can I achieve the so called "one-...
0
votes
1answer
151 views

read line by line and take a string in line and assign that string to the subsequent line using perl [duplicate]

Data file is fixed length file, and I want to read file line by line and take a string from the current line, and then append that string to the subsequent line and write into another file. For ...
0
votes
3answers
236 views

how to remove the empty/blank lines from files that appears as @ from vi

when I open file by vi as vi file Current partition replica assignment @ @ @ @ @ {"version":1,"partitions":[{"topic")] @ @ @ @ @ Proposed partition reassignment configuration but I try to delete ...
1
vote
4answers
190 views

add a new column with sum of columns in perl

I have a huge text file which has below columns col1 col2 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec abc dec 10 20 30 40 50 60 70 80 90 11 12 13 The output I am looking for is an addition of ...
0
votes
1answer
51 views

awk + count the strings from file [duplicate]

I have in file /tmp/users list of users ( each list contain diff users ) Example more /tmp/users root kafka yarn hdfs root root yarn moon apache start moon apache I want to print the users that ...
-1
votes
1answer
282 views

Perl script not found when executed from a different directory than the current one

I am using perl64 on Windows 10 with UWIN installed. I wrote a perl script, sv2jb.pl, which runs fine when invoked under ksh by just typing its name, and when it is in the current directory. I then ...
3
votes
3answers
7k views

How to do a regex search in a UTF-16LE file while in a UTF-8 locale?

EDIT: Due to a comment Warren Young made, it made me realize that I was not clear on one quite relevant point. My search string is already in UTF-16LE order (not in Unicode Codepoint order, which is ...
0
votes
0answers
15 views

How to create separate files based on first column value? [duplicate]

It is tab separated 3 column file. I need to create separate files based on first column value Input: 194501 CAD 1.47421052631579 194517 CAD 1.39578947368421 194520 CAD 0.949473684210526 194501 ...
0
votes
1answer
681 views

Perl script to format .xls file in Linux [closed]

All I have is a linux command (I don't know what's behind the command, the script or what formats the command output), so what I can do is to pull the data [which is in table form with invisible ...
-2
votes
1answer
59 views

how to match single pattern and replace it with multiple pattern in perl [closed]

i have one file which contain following info - input - a[1]= something_data_1; a[2]= something_data_2; a[3]= something_data_3; so i want to replace that "a" with different pattern like below, ...
1
vote
1answer
850 views

mkdir command not found?

I think I messed up the PATH. I was installing Bioperl and tried to changed path. The correct code should be: $ export PATH=/usr/local/ActivePerl-5.26/bin:$PATH $ export PATH=/usr/local/ActivePerl-5....
1
vote
1answer
60 views

Disable Tomcat Session persistence using sed or perl

I need to disable Tomcat session persistence as I have implemented SpringSession on my Spring (not Spring Boot) Application. I've tried using sed and perl to edit multiple lines in the context.xml ...
1
vote
1answer
62 views

How to prevent from destroying symlinks, using Perl when to replace with sed regex?

Based on How do I prevent sed -i from destroying symlinks?, but I use Perl. I tried by middle of all these questions: Is there a way to make perl -i not clobber symlinks? perl symlink on gz file How ...
1
vote
1answer
548 views

Alias for perl script

So far while surfing web I've discovered nice addition to my gpg password generator and I've decided to adjust my alias with these commands. Here is the code gpg --gen-random 1 20 | perl -ne'print "...
2
votes
1answer
312 views

Why does this simple Perl client not work?

I am using IPC with sockets. I'm trying to understand why I cannot get this example script from perldoc perlipc to run on my Ubuntu setup: #!/usr/bin/perl -w use IO::Socket; $remote = IO::Socket::...
2
votes
2answers
125 views

Add a number in a huge ASCII file

Background: (1) Here is a screen capture of a part of my ascii file (over 600Mb): (1.1) Here is a part of the code: 0, 0, 0, 0, 0, 0, 0, 0, 3.043678e-05, 3.661498e-05, 2.070347e-05, 2.47175e-...
5
votes
5answers
9k views

fixing cpan by resetting it

So I ran into a simple little problem. I wasn't connected to the internet and started cpan. It started to configure for the first time and then when I realised a few seconds later that the internet ...
1
vote
2answers
105 views

How to start a new column after every nth row?

I have a file (comma separated) on a Linux system with 3 columns. I want to start new column after every 4th row. Input: col1,col2,col3 1,disease1,high 1,disease2,low 1,disease3,high col1,col2,...
0
votes
1answer
33 views

Remove non-alphas while ignoring certain unicode chars

I have a text like the following: []përgjithshme [" është "] 28.748 [< kilometra katrorë.>] This text contains cyrillic characters in the range U400 - U4FF. I want to strip out the non-...
0
votes
0answers
37 views

Script can not write into dierectory

I have configured apache web server on fedora 29 , perl script that generates web page with current NIC information (state , speed , mac , etc.) and traffic graph. Script generates the web page and ...
0
votes
1answer
273 views

Print line and following text based on pattern matching

I am trying to filter lines from a text file based on patterns in proceeding lines which keeping the pattern matched line. I also need to rename the pattern matched files for example: >text chr1 ...
0
votes
1answer
146 views

tracking segfault upon invocation of perl script (mytop tool and similar)

on my gentoo machine, mytop 1.9.1 quits upon invocation with the following output: # mytop Useless use of private variable in void context at /usr/bin/mytop line 1001. "my" variable $data masks ...
1
vote
1answer
646 views

carton: command not found

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 build-essential. When I run ...
2
votes
5answers
4k views

Replace all but a set of characters in a file with newline

how to delete all characters in file except numbers and "." , each word (numbers/dot) should be in new line in file see example2 the solution can be with sed or awk or ksh syntax remark - the ...
4
votes
3answers
371 views

Manipulating text in first column only? [duplicate]

Example Input: foobar@example.com foo@example.com,bar@example.com Example Output: foobar@example.org foo@example.com,bar@example.com So, in "normal" circumstances, it would obviously be easy to do ...
1
vote
5answers
262 views

Remove text between consecutive occurences of strings

I need to remove all text between two given strings in a text file. The strings may be located on different lines. For instance, in the following text file @article{ginsberg_lifespan_2018, title =...