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
1
vote
2answers
54 views

Howto find the size of a remote http/https directory (non recursively) using a given regexp from the command line

I'm trying to find the size of a remote http/https directory (non recursively) using a given regexp (\.mp4) from the command line, is there a tool to do so or do I need to parse the index.html ? ...
-1
votes
2answers
94 views

How to make code interpret $ but not *? [closed]

I have some perl code (don't focus on what it does right now, i'm still working on it): #!/usr/bin/perl -w if(!@ARGV) { print ("ERROR: NO ARGS\n"); exit 1; } else { use Cwd qw(cwd); my $dir ...
-2
votes
2answers
55 views

How to remove entire array that have specific character

I have a perl code that extract from .xls file. My .xls file is as below NUMBER NAME ALPHABET one Jane a two Adam b three Josh c ;four five Agnes ...
6
votes
8answers
1k views

Delete nth line (when counted from the bottom)

There are unknown number of lines in a file. How to delete nth line (when counted from the bottom) with one-liner command (you may use more than one if it is necessary) on Unix platform.
1
vote
2answers
63 views

fastest way to subsitute on 10GB file for multiple expressions

I have a file of 10GB data, I want to execute 2048 substitution expressions of sed -i 's/pattern/replace_pattern/g' on that file. Is there a way to do it faster and effectively. Currently, I am ...
0
votes
1answer
31 views

Replace middle of filepath while keeping filename at the end?

I am trying to manipulate a file path using bash. The first part of my goal has been completed, where I replace the first half of the file path with the path on my local computer. $> fp=$"/...
0
votes
1answer
45 views

Replace group of similar text in string from nth position with one string else increment the value by +1

I have a text file with following lines for example. Input DD0TRANSID000019021210504250003379433005533665506656000008587201902070168304000.0AK 0000L00000.00 N ...
0
votes
3answers
129 views

Replace text in lines in a file with increments

I have a file with multiple lines (no. of lines unknown) DD0TRANSID000019021210504250003379433005533665506656000008587201902070168304000.0AK 0000L00000.00 N 01683016832019021220190212N0000....
0
votes
0answers
12 views

Log4perl Fails on Linux Lite

I recently re-purposed an old laptop of mine by popping in a new SSD and installing the latest stable version of Linux Lite. I've been trying to get my preferred configuration of Atom running on it. ...
-1
votes
3answers
65 views

how to assign values to intervals with overlapping regions?

I have two big files, the first file contain some intervals with 85K rows: head data.intervals id id_uniq numberA numberB 1 g1 5 20 1 g2 6 29 1 g3 17 35 1 g4 37 46 1 g5 50 63 1 ...
2
votes
1answer
69 views

uniq -c Equivalent for Groups of Lines of Arbitrary Count

I've got a file of ~1-2 million lines that I'm trying to reduce down by counting duplicate groups of lines, preserving order. uniq -c works okay : $ perl -E 'say for (("foo") x 4, ("bar") x 4, "baz"...
0
votes
2answers
540 views

How to install Perl modules on Debian 9?

On a tutorial for installing SendEmail, I found instructions to install 2 prequisites, 2 perl modules apt-get install 'perl(Net::SSLeay)' 'perl(IO::Socket::SSL)' This syntax also resulted strange to ...
0
votes
2answers
49 views

How to append line with strings at the end of variable?

We have the following line in file more file USA_FORMAT="-XX:LOP83746=5M -XX:+YU3635-2837" and we want to append the following strings (line) also at the end of USA_FORMAT variable /usr/jdk64/...
0
votes
3answers
155 views

Replace block of text with sed, awk, perl or vim

I am trying to replace every instance of a block of six rows with another block of six rows, just reducing the six rows block of two columns to a six rows block of only one column. Thank you to your ...
2
votes
0answers
84 views

'Out of Memory' on AIX installing Perl Module [closed]

Getting out of memory error trying to install NetFTPSSL perl module on IBM P750 running AIX 7.1 with 76GB of memory. root@polarprod-cip(/)# perl -MCPAN -d -e 'install Net::FTPSSL' Loading DB ...
0
votes
0answers
96 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 ...
3
votes
0answers
498 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: ...
6
votes
3answers
628 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 ...
1
vote
1answer
61 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 ...
1
vote
3answers
75 views

delete lines matching pattern if it is repeated

Say I have a config file: [main] foo = bar [option] opt1 = opt2 opt3 = opt4 [extra] [footer] [tail] print = true [end] I want to print the headers ([text]) only if there are options underneath. So ...
0
votes
1answer
41 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 ...
1
vote
2answers
92 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 ...
2
votes
1answer
269 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 ...
0
votes
5answers
138 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
3answers
144 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
119 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
47 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
226 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 ...
0
votes
0answers
14 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 ...
-2
votes
1answer
58 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
611 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
39 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
46 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
2answers
70 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
27 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
91 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 ...
4
votes
3answers
365 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
228 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 =...
0
votes
1answer
42 views

how to add words before line on all the scripts in current folder

under /home/scrript , we have 187 bash scripts all the scripts have the following line: kill -PIPE $PID we want to add the following words before this line on all the scripts as the following [[ $...
0
votes
1answer
115 views

Get lines of file matching a regex

Is there a more compact way to get lines of a file that match a regex than the following? open my $fh, '<', $file or die "Cannot open $file: $!"; while ( my $line = <$fh> ) { next ...
0
votes
2answers
1k views

Check which process is using most memory and summary total used memory

by the following command we can check which process is using most memory as we can see the first field show in MB the used for each process is it possible by awk to sum all the numbers and to get ...
0
votes
1answer
60 views

Insert new text in the middle of a file replacing old text without re-inserting the same things over and over?

I have a file that I want to update relatively frequently. What needs to be done is that a specific part of the file would be changed to include some more lines. I am doing it with sed and \a option: ...
0
votes
1answer
228 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
107 views

Perl script for generating MAC addresses

This perl line very useful to change mac address but retain the first three pair. perl -e 'for ($i=00;$i<6;$i++){@m[$i]=int(rand(256));} printf "00:16:3E:%X:%X:%X\n",@m;' Generate some good ...
4
votes
3answers
305 views

Get one thing from a line and concatenate it with one thing from another line

I have the following: 2018-11-10 23:57:21 [COMMAND]: sar -u 10 5 AIX host 1 7 11/10/18 System configuration: lcpu=64 mode=Capped 23:57:21 %usr %sys %wio %idle physc 23:57:31 ...
5
votes
2answers
562 views

Perl command line regex to modify all pattern matches

I'm trying to use some arithmetic over the matched patterns in perl command line. I'm able to do it for one match but not for all. str="a1b2c3" perl -pe 's/\d+/$&+1/e' <<<"$str" a2b2c3 ...
1
vote
2answers
147 views

Install custom perl modules

I have build an RPM from a proprietary software collection in a CentOS 7 environment but the build process required executing some Perl modules (.pm files) found within the source itself. When I ...
2
votes
0answers
34 views

How do I display file modification time (linux) as “Nov 8 12:00” format? [duplicate]

The format I want is "Nov 8 12:00". It is the format you get by using the ls -l command. It is month, day of the month, hour and minute. I tried stat -c %Y filename which gives time of last data ...
2
votes
1answer
85 views

Can I change terminal type used to login through Net::SSH in perl?

When I login on some particular server through Net::SSH in perl (which I do not have admin access to), I get the following error: %SECURITY-SSHD-4-WARNING_LOGIN : The requested term-type '' is not ...