Skip to main content

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.

1 vote
1 answer
1k views

Find server with small ping latency (my script, but can anyone write it in e.g.: Perl?) [closed]

I want to download OpenBSD with FTP with a script, and I want to download it from a server that is near me. So I want to choose a mirror that has low "ping latency". I wrote a little script, that ...
LanceBaynes's user avatar
  • 40.6k
41 votes
9 answers
28k 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 ...
Cory Klein's user avatar
1 vote
1 answer
1k views

How to convert <a href="http://xy.com">XY</a> to [http://xy.com XY]?

Just for editing Wiki's.. So i have this input [from a larget text]: TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA TEXT TEXT <a href="http://xy.com">XY</a&...
LanceBaynes's user avatar
  • 40.6k
4 votes
5 answers
7k views

Replacing text from a list of replacements. Added complication: backslashes

I have a file A that contains pairs of strings, one per line: \old1 \new1 \old2 \new2 ..... I would like to iterate over file A, and for each line perform the replacement (e.g. "\old1 -> \new1") ...
Leo Alekseyev's user avatar
10 votes
6 answers
5k views

Is there any alternative to grep's -A -B -C switches (to print few lines before and after )?

grep -A 2 -B 3 prints 2 lines after the grep string and prints 3 lines before. grep -C 3 prints 3 Lines before and 3 lines after Unfortunately, the grep I'm using does not support these options. ...
Prashant Bhate's user avatar
3 votes
3 answers
2k views

Get last set of non-empty lines

I'm running a cron job which should get only the last result of iostat -d 1 2. This requires some parsing: What is the simplest way to get the last set of non-empty lines from standard input to ...
l0b0's user avatar
  • 51.8k
13 votes
3 answers
1k views

Is there a way to make perl -i not clobber symlinks?

A friend of mine points out that if you do: perl -pi.bak -e 's/foo/bar/' somefile when "somefile" is actually a symlink, perl does just what the docs say it will do: It does this by renaming the ...
mattdm's user avatar
  • 40.5k
2 votes
2 answers
284 views

Perl find and replace is writing every file

Here's the test script I'm running matt@server:~ $ cat test.sh #!/bin/bash mkdir test cd test echo "has the string foo" > yes.txt echo "hasn't the string" > no.txt ls -l --time-style=full-iso ...
Matt Alexander's user avatar
5 votes
3 answers
9k views

piped program in sendmail's /etc/aliases

I'm trying some sort of auto-subscription via a homegrown script. I know it can be achieved by mailing lists such as Mailman but I also want to learn at the same time on how to do it by hand. Here's ...
icasimpan's user avatar
  • 439
4 votes
1 answer
2k views

Query DHCP server leases from Perl script

I have a Windows 2003 server and need to poll the DHCP lease information from it with a perl script that is running on a Ubuntu server. Then I need to analyze & store the information in a mysql ...
BrNathan's user avatar
  • 185
28 votes
3 answers
32k views

How can I install perldoc on Ubuntu?

Ubuntu 10.10 comes with Perl 5.10.1 pre-installed, but strangely enough perldoc isn't part of the package. $ perldoc You need to install the perl-doc package to use this program. How can I make this ...
Zaid's user avatar
  • 10.8k
2 votes
4 answers
5k views

Using regex to see if a UNIX process is up

In UNIX, I am checking to see if a process is up by executing the following command; E.g. psg dtllst pe99 This returns the following output if the process is running; UID PID PPID C ...
user avatar
15 votes
1 answer
31k views

Execute Nohup command with input

In UNIX, I have a process that I want to run using nohup. However, this process will at some point wait at a prompt where I have to enter yes or no for it to continue. So far, in UNIX I have been ...
user avatar
9 votes
1 answer
15k views

Replacing multiple lines in sed or awk [closed]

I'm trying to use sed or awk to replace 5 lines in a smb file but I just don't have any idea how to deal with the newlines.
glisignoli's user avatar

15 30 50 per page
1
87 88 89 90
91