Tagged Questions

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

10
votes
2answers
115 views

Resource friendly way to indicate to user program is not hanging

I have a Perl script on a *nix system which, at one point, is processing 50,000 + lines of text. This takes some time. I am trying to find a resource friendly way to let the user know the program is ...
0
votes
3answers
147 views

Count words: what will use less CPU, wc or a perl script?

My objective is to count the words in a file while using the minimum possible CPU. I could use the wc command or write a simple perl script for this, which of the two options will be less CPU ...
2
votes
2answers
233 views

When Adding IPs with ifconfig eth:xx, how do I in one line find the highest eth:xx

This will be in a Perl script I need to grab that number and increment it by one for the new IPs. Any one have a one liner for me? Can be Bash/Perl. edit Given the following input. inet ...
3
votes
2answers
3k views

find files not matching list of filename patterns

I find myself needing to find and identify extraneous files (out of about 900K files on a 2T drive). There are lots of files that I want to keep, and I have filename patterns for these known good ...
2
votes
1answer
98 views

Why the order of wildcard results might be different when used from the terminal or from perl?

There's a folder with a bunch of files and a perl scrip that lists them using ls with a wildcard like: #!/usr/bin/perl system("ls -U -1 dir/*"); I noticed that if I run exactly the same command ...
1
vote
1answer
138 views

How to safely move a file to another directory and remove duplicates

I want to move files from Downloads, Documents, Pictures, Music, et al to shared locations. This is for various reasons, including because I want to keep media in a central, shared place. I want to ...
1
vote
1answer
88 views

How to mention rpm to look for dependent perl modules in the system

By default rpm looks for the perl modules inside the rpm itself and throws dependency error if it is not found. For eg., I have a perl script in the rpm that uses Crypt::DES perl module. I have that ...
1
vote
2answers
136 views

Why `rename` behaves differently whenever I use full path instead current path?

Ok, I'm answering a question where the OP have several repositories in Ubuntu that might be causing a problem installing unrelated software. I recommend disabling the PPA's using a single liner rename ...
1
vote
1answer
122 views

Parsing the headers of sequence file

I have a multiple sequence file as >abc|d017961 sequence1...... >cdf|rhtdm9 sequence2...... >ijm|smthr12 sequence3...... >abc|d011wejr sequence4...... >stg|eethwe77 sequence5...... ...
0
votes
2answers
99 views

How to write a job in Perl?

I have had very minimal experience in writing jobs. A long time ago, i had written a very small simple java job for reading and writing files using tasklet in java. Now I have to learn how to write ...
1
vote
2answers
742 views

squid access.log delete entries older than 6 months

Squid generates a log of the accessed sites by the users. I want to delete the entries in the /var/squid/logs/access.log, which are older than 6 months. I would execute the script each week. I have ...
1
vote
3answers
3k views

How to convert from one date format to other format?

I have one problem with my date format. I want to change from one format to the other and vice versa. My date formats are Format 1 YYYY-MM-DD Format 2 MM/DD/YYYY I want to change format 1 to ...
4
votes
6answers
102 views

Only show the lines that are in all textfiles at least once

a.txt cat a.txt a b x c b.txt cat b.txt d e a f the q: SOMEMAGICK *.txt a Q: how can I show only the lines that are in all *.txt files?
1
vote
1answer
65 views

how to clean free row/column spaces after the row of your data

I have a problem in cleaning my file where there are unnecessary free spaces below my last data row. This is created when I am copying and pasting my data from excel to text. I want my text file to ...
1
vote
1answer
111 views

How do I modify this Perl solution so that it will substitute embedded double quotes with single quotes?

Previously in this question: "string having doublequotes in between apart from the enclosing quotes" @BernieReiter asked a follow-up question where he wanted to take CSV entries such as the following: ...
0
votes
1answer
51 views

How to split files?

Input.txt line.....1 line.....2 line.....3 ..... line.....3 line.....4 line.....5 ..... line.....4 line.....5 line.....6 ..... line.....5 line.....6 line.....7 ..... Condition for output file ...
3
votes
3answers
4k views

importing data from a text file to a bash script

I need to import a text file like this below: AMBI CBNK CCXI CERE CLACW CNYD DAEG DLIA DLLR DNDN DSGX HAST HIBB, HPOL IRDMZ MARK NEPT NFEC NINE NRCIB OMER PLCC PLPM PSUN UNTK There are 25 entries, ...
-1
votes
1answer
479 views

How can I split a file into multiple files based on pattern using perl? [closed]

How can I split a file into multiple files based on pattern using perl? Ex: input to be a .txt file, name of the output file stored in another .txt file
0
votes
1answer
542 views

Automation tasks for system administrators [closed]

If I am a junior UNIX/Linux system administrator, and I want to make automation tasks for the server. I know Shell script, Perl, and Python. All of these are used to make automation tasks. Which one ...
1
vote
3answers
570 views

How to limit MAX an MIN length of a string?

"nothing" means no OUTPUT. Q: how can I limit the MIN and MAX length of a piped STRING? (MIN: x>=3 chars, MAX: x<=32 chars) INPUT: echo 12 | MAGIC OUTPUT: nothing INPUT: echo 123 | ...
1
vote
1answer
53 views

How to make URL's out of this text with least resources?

INPUT: nyeeeeeeeeeeeeeee.txt:sadfsadf sadjflsajfd:jasdlfjalsfd foo/asdfsafd.txt:laksjdlfajsfd OUTPUT: <a href="nyeeeeeeeeeeeeeee.txt">nyeeeeeeeeeeeeeee.txt</a>:sadfsadf <a ...
1
vote
1answer
129 views

Why wouldn't Perl CGI script run

I'm using Apache on CentOS and am trying to run a Perl CGI script as directory index so it will run automatically as a subdomain. I added DirectoryIndex script.cgi and added a Directory stanza noting ...
0
votes
2answers
89 views

Programmatically get folders last edit time

How can I programmatically get a folders latest edit? I have already written the following script: #!/usr/bin/perl my @ls_command_result=qx(ls -l); my @the_folder=grep /folder_i_want/, ...
2
votes
1answer
266 views

how to replace IP address on remote host using expect

I wrote the following expect script in order to replace the IP address on remote Linux machine I use a perl one-liner for this task I get errors about can't read "HOME": no such variable , Please ...
5
votes
1answer
204 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
1answer
2k views

Forcing Bash to use Perl RegEx Engine

As you may already know, a lot of the features modern RegEx engines support (back referencing, lookaround assertions, etc.) are not supported by Bash RegEx engine. Following is a simple Bash script I ...
1
vote
2answers
682 views

fixing cpan by resetting it

So I ran into a simple little problem. This is a somewhat rookie mistake. I wasn't connected to the internet and started cpan. It started to configure for the first time and then when I realised a ...
0
votes
1answer
175 views

Read and parse XML input via TCP [closed]

I'm setting up something where I'll need to be able to setup a service that accepts input on a TCP port and then parses the XML provided and extracts the necessary data, then posts that to Google's ...
2
votes
6answers
3k views

Repeat each line multiple times

Would like to have each line in a file repeated a fixed number of times. e.g. have each line repeated four times: a b c becomes: a a a a b b b b c c c c I've done some searching, and there are ...
0
votes
3answers
388 views

according root permission to www-data

I have a perl script dhcpmanip.pl which contain this line: system "hostapd /etc/hostapd-1.0/hostapd/hostapd.conf"` It's a command to start hostapd and I get this error : Insecure `$ENV{PATH}` ...
2
votes
2answers
301 views

How can I use procmail to modify the body of an email and then forward it to an external address?

I'm struggling to get procmail to first transform, and then forward, a received email. Here's what I'd like to do: :0 f | ~/bin/encryptemail.pl | mail foobar@gmail.com That is, I want to run the ...
1
vote
1answer
579 views

How to filter an array of strings in ksh

Please advise what's wrong in my ksh code. 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 ...
2
votes
2answers
149 views

ksh + delete number from string

the string IP include some IP address numbers as the following example echo ${IP[*]} 192.9.200.1 192.9.200.2 192.9.200.3 is it possible to remove some IP address number from the list ( using ksh ...
1
vote
2answers
298 views

perl one liner + how to match IP address that located in the first/sec field of file

the following perl one liner syntax verify if IP address in "$IP" match the IP ADDRESS in file perl -ne 'BEGIN{$IP=shift} print if /(^|\s)\Q$IP\E(\s|$)/;' $IP file file have two fields as the ...
2
votes
2answers
157 views

linux & solaris - separate netmask IP's from ordinary IP's

I have file with IP address and netmask IP's my target is to cut the netmask IP's from the file_with_IPs.txt and paste them to another file as file_with_only_netmask_ips.txt remark - netmask IP can ...
-3
votes
4answers
685 views

perl one liner + how to replace any last IP address octets

How to replace any last IP address octets (four octet ) to 0 remark: Implementation should be by Perl one linear on linux machines for example 192.9.200.124 will replaced to 192.9.200.0 ...
3
votes
2answers
262 views

No idea how to troubleshoot Bugzilla email issue

I'm a complete n00b when it comes to Bugzilla (and complex perl applications in general) so don't assume any level of knowledge in that area. If I haven't documented it in this post, assume I haven't ...
1
vote
2answers
393 views

Perl - /etc/shadow - Permission Denied

The following command is being executed by a non root user : perl -pi -e 's/^an24:/an24:\*LK*/g' /etc/shadow A permission denied is being issued. This indicates some privileges issues. Can such ...
-2
votes
1answer
215 views

Difference between command line argument and giving an input command [closed]

What is the difference between @ARGV and asking the user for input? $num = $ARGV[0]; and $_ = <STDIN>; Either way a user has to put an input isn't it? How are they different?
-4
votes
1answer
126 views

Usefulness of @ARGV in Perl [closed]

What is the difference between using just normal arrays and the special array (command line argument)? Normal array: @num(1,2,3,4), and you can use $num[0], etc Special array: you have to use @ARGV, ...
-2
votes
1answer
59 views

Perl confused with script [closed]

Write a perl script that takes one argument, the name of a file or directory. The script should call the stat function and print the resulting data along with a one line explanation of each field. my ...
-2
votes
1answer
76 views

Perl Script Explanation [closed]

#!/usr/bin/perl -w use strict; my $args; $args=@ARGV; if ($args<1) { die("Expecting a filename"); } sub showstat { print " $_[0] dev, device number of filesystem\n"; print " $_[1] ...
2
votes
3answers
1k views

I want to find duplicates in a file and add a character to the end of the line on the 1st match

I am trying to find duplicates in a file and once a match is found mark the 1st match with a character or word on the end of the line. eg my file (test.html) contains the following entries host= ...
-2
votes
1answer
102 views

Perl only one option at a time [closed]

There is a requirement where I can't put two options at the same time. For instance with -a option: file.pl -a file.text # executes file But if I write file.pl -a -a file.text # it is ...
3
votes
2answers
269 views

Passing quotes and full strings to bash -c or zsh -c

When I am in Perl and I call system(some_command), this invokes some_command on /bin/sh. I would like it instead to run some_command in another shell such as bash or zsh. One way of running ...
-3
votes
1answer
90 views

perl script explanation please [closed]

Write a perl program that reads in a text file containing one word per line. Create a hash containing the words read as keys and the number of times they have been read as the value. Print ...
2
votes
3answers
2k views

Easy way to parse syslog date format

I'd like to write a script that analyses the last week's syslog. But my syslog logs in a stupid date format, e.g. "May 22". If it logged as 2013-05-22, this task would be trivial. Is there a way ...
3
votes
3answers
168 views

sed + how to remove character/s that start or ended on each number

How do I remove the . character(s) that start in the beginning of each number or end on each number? Remark – perl one liner also good alternative for sed. Example input: .23.12.44.5. .233.3.3.3 ...
1
vote
1answer
196 views

Perl dependency issue

I've installed CentOS 6.3 (i386) recently. It has two perl binary /usr/bin/perl (v5.10.1) /usr/local/appx/perl/bin/perl (v5.8.8) My question: Is it possible to install some other funtinonality ...
6
votes
2answers
595 views

Special character '#' in Perl SSH command

I try to send command using SSH in my perl script with # but it gets truncated right at # Example: Input text is : $message = "Product ID # STK000134" The SSH command is : $execute=`ssh -q ...