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
0 answers
44 views

Why are my forked processes being killed?

I'm running on a Red Hat RHEL 7.9 server. I have a Perl script which repeatedly calls fork() to run several hundred different small C-based programs. It only runs about 10 programs at a time (my ...
user avatar
  • 323
-2 votes
1 answer
69 views

Organising column and items based on corresponding value from different column

I have a large input.csv file that has 2 columns: Category (column A) and Item (column B), each Item having that specific Category found on column A and one row higher than the group itself; ex: rows ...
user avatar
0 votes
0 answers
24 views

Script to create batch of objects

I'm very new to Perl. I need to run a command but within that command call IP's and hostnames from a csv file. trying to accomplish this here is my code. I'm know it won't make sense but trying to get ...
user avatar
3 votes
4 answers
240 views

Replace a base64 value in a file in unix

I have a problem, I have a file test.txt that has a content like this: objectClass: CPM1 objectClass: CPM2 objectClass: CPM3 objectClass: CPM4 objectClass: CPZ objectClass: CP04s objectClass: CP0A ...
user avatar
0 votes
0 answers
23 views

why do not the programe moving ahead?

I do write a practice perl script from book is not running ahead from 2nd line it remaining on on line anybody can tell me what is the problem in the programe.
user avatar
1 vote
2 answers
155 views

Remove specific CSV columns from large CSV file and duplicated rows with Perl

I have a large CSV file (300MB+) and I want to remove only columns 2,3 and 6-8 using Perl AND remove duplicated rows: Note 1: all columns are separated by , (commas) but sometimes my cell values ...
user avatar
1 vote
5 answers
82 views

How do I replace all the spaces in just a substring of certain lines in a file?

I have 3000 Markdown files named "journal/*.md", some of which contains file links like this: blah blah text [Label here](file:///path/to file/may contain/spaces) I want to change all such ...
user avatar
  • 111
-1 votes
1 answer
40 views

write bash code loop a file line by line that have values, first word as a row and create csv [closed]

i have this sample data dn; uid=456456456,cn=users,dc=efsfb,dc=org,dc=co; objectclass; top; objectclass; person; objectclass; organizationalPerson; objectclass; inetOrgPerson; uid; 456456456; ...
user avatar
  • 101
3 votes
1 answer
96 views

How do I remove anagram duplicates from a list?

I have a tab-delineated .csv with strings and descriptions. A bit like this: strap tight elba Island foo bar able Cain parts buy able Cain First, I'm sorting the file by length of ...
user avatar
  • 31
0 votes
4 answers
45 views

extract and compare block of text

I have a data gethered in one file organised in blocks ---- BLOCK ONE ---- some data another data more data more data ------------------- ---- BLOCK two ---- some data another data -------------------...
user avatar
  • 3
0 votes
1 answer
65 views

Sorting lines based on certain digit pattern

Assume I have a text file with the following lines: 192.168.1.1.55555 192.168.1.1.55555 192.168.1.1.5555 192.168.1.1.555 192.168.1.1.55 192.168.1.1.55 192.168.1.1.5 8.8.8.8.4433 8.8.8.8.443 8.8.8.8....
user avatar
0 votes
0 answers
19 views

Convert GDBM to new GDBM

I have a GDBM file in old format that I want to convert to GDBM in new format: Have: my.db: GNU dbm 1.x or ndbm database, little endian, old Want: my.db: GNU dbm 1.x or ndbm database, little endian, ...
user avatar
  • 29.6k
2 votes
4 answers
296 views

sed + add string on the beginning of line but ignore if already exist

here is example how to add string on the beginning of line when match the UUID number in fstab sed -e "/UUID=953b1921-ac73-4b7b-abaf-ff983b0fce8a/ s/^/###FAULTY_DISK###/" -i /etc/fstab and ...
user avatar
  • 10.9k
0 votes
0 answers
12 views

Is cpanminus delayed/behind?

cpan(-outdated) tells me GD is a version behind, but cpanm appears not to see this new version ... Is it expected behaviour that cpanm lags behind by some amount? If so - why, and delayed by how much? ...
user avatar
  • 413
1 vote
4 answers
174 views

comment the specific line in fstab file that contained the relevant UUID number

We want to comment the specific line in fstab file that contained the relevant UUID number Example: Disk=sde UUID_STRING=` blkid | grep $Disk | awk '{print $2}' ` echo $UUID_STRING UUID="...
user avatar
  • 10.9k
0 votes
0 answers
26 views

Read List of URLs to obtain informations

Can you complete this Perl/bash script for a url and for a list of urls and tell me how to write several regex in the same script? wget -Otest.html https://www.cormes.de/impressum perl -nE '...
user avatar
3 votes
1 answer
80 views

Best way to remove and replace different characters from multiple filenames?

I have several folders full of files with the following format: Show Name - 07x09 - Episode Title.mp4 What I'm trying to do is rename them to the following format: Show.Name.S07E09.Episode.Title.mp4 ...
user avatar
6 votes
8 answers
497 views

Make change operations on substring only

In a file that has any garbled text before and after a section that is marked by patterns START and END (specific strings that occur only once each and in the correct order and on the same line). I ...
user avatar
  • 10.6k
0 votes
1 answer
68 views

bash script checking if file is binary or text using perl?

Can someone explain how this bash script piece works? is_text_file() { perl -e 'exit((-B $ARGV[0])?1:0);' "$1" } Thanks.
user avatar
0 votes
2 answers
83 views

Manipulating CSVs in Unix - best native Unix tools to learn [closed]

I am new in the Unix environment. I am looking to learn manipulating CSV files (for example: adding new columns, getting values from one CSV by index and appending the value in a new CSV file etc.) in ...
user avatar
0 votes
0 answers
68 views

search string with ack in linux OS while exclude non relevant folders

We installed the ack tool as follows (from - https://beyondgrep.com/install/) curl https://beyondgrep.com/ack-v3.5.0 >/bin/ack chmod +x /bin/ack Now, we want to search the string --> jessica in ...
user avatar
  • 10.9k
0 votes
1 answer
19 views

Retrieving hosts from a URL list using Perl's Regexp::Common::URI::http library

Presently I'm getting a list of URLs from a text file like so: perl -MRegexp::Common=URI -nE 'say $& while /$RE{URI}{HTTP}{-scheme => "https?"}/g' urls.txt And am wondering how to ...
user avatar
  • 139
-1 votes
6 answers
96 views

delete string ending with a pattern for each column

I would like to delete all entries with (L=6), (L=7).....(L=12) occurring in a file randomly the following format; my input file: TRINITY_DN1910_c0_g1_i13 GO:0005975(L=2) GO:0006022(L=4) GO:0006026(...
user avatar
0 votes
1 answer
38 views

match column1-5 in both files and print matching column1-5 along with column6&7 of file1 and column6 of file2

want to match column 1-5 in 2 files and print column1-5 along with column 6&7 from file1 and column6 from file2. Non-matching rows from both file should also get printed with NA value in non-...
user avatar
  • 25
2 votes
2 answers
152 views

Find a pattern (of a child tag) and replace the entire parent tag at XML files, without using sed tool [duplicate]

Is there a way to find a pattern (of a child tag) and replace the entire parent tag, using regular expressions?  I'm working from a Linux server without a graphics environment. I have XML like: <?...
user avatar
0 votes
0 answers
85 views

Trouble installing DateTime from CPAN

I'm trying to install the DateTime module. I went into CPAN from a terminal and started the install with make. It ran for hours and when it finally stopped, the last line simply said 'killed'. My perl ...
user avatar
1 vote
4 answers
101 views

Parallel execution of remote commands

The setup: I have a PHP script (currently written for PHP5.5, but the server it runs from has 7.4) that processes files that contain lists of linux servers, then runs a bash or perl script via ssh on ...
user avatar
  • 131
0 votes
0 answers
19 views

Perl debugger command history not save one character ones

Why does the perl debugger command history not save single character commands? DB<230> n main::(rmHTMLement.pl:13): print 'Removing element in file: '; DB<230> Then, I cannot ...
user avatar
0 votes
2 answers
125 views

Extract function string before function name with regex

I want a regex that would search for something like: package_name.some_function_name.foo() that would be part of a line and would and extract the some_function_namebut it should be able to work ...
user avatar
  • 1,195
0 votes
0 answers
23 views

The URxvt.keysym.Shift-Insert: eval: not working

why this shift + insert binding not work URxvt.keysym.Shift-Insert: eval:paste_clipboard How is it supposed to be set then work ?
user avatar
-1 votes
1 answer
80 views

sh + how to send cntrl c and then enter yes to accept license

I need to enter CNTRL C and then I need to enter yes , in order to accept license now I am thinking how to automate this process can we automate this process as run the sh script and entering CNTRL C ...
user avatar
  • 10.9k
1 vote
0 answers
32 views

Using debugger by perl -d -e "1;" with readkey or readline

When using perl -d -e "1;" inspect few importances so asking: What is the difference in term::readkey and term::readline Just found readkey one not behave correctly like Bash shell readline ...
user avatar
4 votes
1 answer
59 views

Perl - closing curly bracket before the opening one. How does it work?

I came across this solution to reverse the content of a file : $ cat f1 abc def ghi jkl $ perl -ne 'push @arr,$_;}{print reverse @arr;' f1 jkl ghi def abc Could someone please explain how the curly ...
user avatar
0 votes
2 answers
88 views

How to substitute a block of lines inside a file?

I want to change the multi-line contain foo2 to be like desired output foo2 is like an array in multiline, how to change it to be in one line FROM: $ cat file.txt foo1=bar1 foo2=('bar10: some text ...
user avatar
1 vote
2 answers
110 views

extract fields based on a string (partial and exact)

Expertos: I want to extract fields based on a string (partial and exact). In some rows these fields are moved one or two columns, so I can't specify the column (which is the extent of my knowledge). I ...
user avatar
  • 559
0 votes
4 answers
160 views

How to extract value between parentheses where before there is a specific string with AWK

Im able to capture all values between parentheses with awk expression 'NR>1{print $1}' RS='(' FS=')' But im struggling to match one in specific, where i do not want to match by line number but by ...
user avatar
0 votes
1 answer
42 views

Weird ptp-bin directory

In my home directory the ptp-bin/ appeared. It contains one file ptp with the following content: #!/usr/bin/perl require("File/Spec.pm");my@files=();my$aflag=0;my$type=undef;for$a(@ARGV){if($...
user avatar
2 votes
3 answers
388 views

Irregular argument count by xargs

Why are the numbers so irregular? echo {1..200000} | xargs perl -E 'say "ok:", scalar @ARGV' ok:23691 ok:21840 ok:21840 ok:21840 ok:20261 ok:18720 ok:18720 ok:18720 ok:18720 ok:15648 It's ...
user avatar
0 votes
4 answers
41 views

Replace TAGS in FileB with VALUE from FileA

I am looking for some assistance in perl, please. I have most of the code built, but I am finding one part particularly challenging. If FileA: tag1=value1 tag2=value2 and FileB: value1=<tag1> ...
user avatar
  • 1
-1 votes
1 answer
39 views

I want to replace a specific word in a text file and save the results in multiple text files using perl or ubuntu command?

I have a file results.txt that contains the following: the word: word1 is a not detected And I have a txt file contain the list of words as following: word1 word2 word3 ... And I want to generate ...
user avatar
2 votes
0 answers
102 views

Extracting html data using perl script

This is my code to extract certain data under the header Item Drop%. I want to extract the 90.5% under that header. But i can only extract the whole column not just that value. any idea ? #!/usr/bin/...
user avatar
0 votes
1 answer
140 views

TCSH: 'Can't find string terminator' Error From perl -e in TCSH Script

I'm seeing this error from my tcsh script and I can't figure out why. Script: #!/usr/bin/env tcsh foreach n (0 1) set PERL_CMD = "perl -e 'print qq^RUNNING^; exit ${n} '" echo "...
user avatar
1 vote
2 answers
65 views

Retrieve latest data from directory

I want to retrieve number of lines from data.list in this directory : Project/chris/company/Delta/force/run_20210619_df/total/data.list But the problem is the run_20210619_df changes and is replaced ...
user avatar
0 votes
1 answer
89 views

Saving hashed string in a variable

I need to hash a string with SHA-512 algoithm. I have a salt also. I'm trying in the script this: inputHash=$( perl -e 'print crypt("${array[3]}","\${pass[0]}\$${pass[1]}\$") . &...
user avatar
3 votes
2 answers
95 views

Squash file with key-value records to CSV [duplicate]

I want to write a data parser script. The example data is: name: John Doe description: AM email: john@doe.cc lastLogon: 999999999999999 status: active name: Jane Doe description: HR email: jane@doe.cc ...
user avatar
  • 1,580
1 vote
1 answer
62 views

If loop not working as intended for perl scrpt

I'm trying to create a Perl script that automatically check for changes in a data.list every hour, username/project/tota/datas/data.list is where the file is and then execute the remaining codes, ...
user avatar
0 votes
1 answer
658 views

Convert this regex to be friendly within sed

I am trying to perform this regex with sed, but seems like sed does not support? It says invalid character range echo "$info" | sed -e 's/(?:\d[\s-.]*){12,19}/*/g' Trying to match any ...
user avatar
  • 103
0 votes
2 answers
117 views

Replacing the seq IDs of fasta file based on the new IDs from a list

I have a fasta file and I want to replace the seq Ids (description lines) with new and extended IDs. This is the format of fasta file: >3C-assembly|contig_74 ...
user avatar
  • 1
1 vote
3 answers
2k views

string interpolation preserving quotes in bash

I have to format body of a json that gets some values substituted from user environment variables. Trying to find a way via shopt or something so the json string is substituted correctly in bash ...
user avatar
  • 147
1 vote
5 answers
151 views

Retrieve job definition of list of jobs listed in the second file

I have a file with 250,000 job details. In this source file, all jobs have different parameters, so the number of lines for each job may vary. The only pattern is that each job definition starts with ...
user avatar

1
2 3 4 5
26