Hi, so far as I know, there isn't any truly easy way to do this in Perl in quite the same way that awk and sed provides.
But there are two Perl apps that will convert awk and sed code into Perl for you, so you can perhaps learn from them instead.
The first being a2p (awk to perl) and the second being s2p (sed to perl)
To answer one of your example questions, you can emulate "head" in sed with the command:
So, to convert that into Perl code and save it to a file for reading. The command:
Would acheive that.
Although, I did say that there isn't any truly easy way in Perl, and you may be quite blown by the output of that command.
Hi everybody:
I try to print in new file selected lines from another file wich depends on the first column.
I have done a script like this:
lines=( "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "21" "31" "41" "51" "55" "57" "58" )
${lines}
for lines in ${lines}
do
awk -v ... (6 Replies)
Hello.
I face this (2 side) problem.
Some lines with this structure.
...........
12345678 4
12345989 13
12346356 205
12346644 74
12346819 22
.........
The first field (timestamp) is growing (or at least equal).
1)Sum the second fields if the first_field/500 are... (8 Replies)
Hi,
I am looking to copy selected lines from a file using the vim editor. I have looked up a few resources and they have suggested to use this-
Type mk
Type: "ay'k (double quotes, <register name from a-z>, <y-yank single quote, k
You can paste those lines wherever you want with "ap
I tried... (7 Replies)
I have an if statement where I state that if there are more than one records (lines) found containing a string in a file, then it enters into a while loop to use each line for as many lines as there are and then stop.
Trouble is, I can't figure out how to move to the next instance of each line. ... (2 Replies)
Hey
I have an input file containing a list of numbers like:
U01120.CDS.1
D25328.CDS.1
X15573.CDS.1
K03515.CDS.1
L44140.CDS.10
U24183.CDS.1
M97347.CDS.1
U05259.CDS.1
And another input file containing results created on the basis of the above input:
G6PT_HUMAN U01120.CDS.1 -1.9450 3.1706... (1 Reply)
I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by
awk 'NR==29,NR==10029' File1 > File2
and then doing
awk '{print $1, $2, $13, $14}' File2 > File3
Can... (3 Replies)
Hello,
I have a file, which looks like:
I want to print the row containg "PRO" in second column after comparing and finding the minimum value of fifth column present in all "PRO". and likewise for every other string present in second column.
I am using :
filename=list... (2 Replies)
Hi guys!
I'm new to scripting and I need to write a script in awk.
Here is example of file on which I'm working
ATOM 4688 HG1 PRO A 322 18.080 59.680 137.020 1.00 0.00
ATOM 4689 HG2 PRO A 322 18.850 61.220 137.010 1.00 0.00
ATOM 4690 CD ... (18 Replies)
hi Gurus,
I have a source file with more than 10 columns ( not fixed )
I want to delete all the lines on the following condition
1) where i have first column as "UPDATE PLAN ADD RATE SCHEDULE" and fourth column as null
awk '($1=="UPDATE PLAN ADD RATE SCHEDULE" && $4=="") {print $0}'... (5 Replies)
two files: one with the line number only, and the 2nd one with line number and content, as following:
line_file.txt
1
3
5
9
23
30
content_file.txt
1|we are the world|good|great
2|easily do this by highlighting you|easily do this by highlighting you|easily do this by highlighting... (2 Replies)
Discussion started by: dtdt
2 Replies
LEARN ABOUT X11R4
perl-after-upgrade
PERL-AFTER-UPGRADE(1) User Contributed Perl Documentation PERL-AFTER-UPGRADE(1)NAME
perl-after-upgrade -- fixup FreeBSD packages that depend on perl
SYNOPSIS
perl-after-upgrade
perl-after-upgrade -f
perl-after-upgrade -v
DESCRIPTION
The standard procedure after a perl port (either lang/perl5.6 or lang/perl5.8) upgrade is to basically reinstall all other packages that
depend on perl. This is always a painful exercise. The perl-after-upgrade utility makes this process mostly unnecessary.
The tool goes through the list of installed packages, looks for those that depend on perl, moves files around, modifies shebang lines in
those scripts in which it is necessary to do so, tries its best to adjust dynamically linked binaries that link with libperl.so in the old
path, and updates the package database.
After installation of the new perl is complete, either by hand from the ports collection, or from a package, or via portupgrade, do the
following:
o go root;
o run perl-after-upgrade utility.
Do not specify any arguments at first, so it does nothing destructive. Pay attention to the produced output and especially to
errorlist at the end, if any;
o run the utility again, with -f command line option.
This will actually do the work. Again, pay attention to the output produced;
o fix any reported errors;
o reinstall required packages:
The utility will tell you what packages that depend on perl it could not handle. It will also tell you why it happened (for example,
they were compiled against a binary incompatible perl). If you want such packages to remain operational, you will have to reinstall
then by hand or via portupgrade.
o review the files left in the older perl installation.
This is typically /usr/local/lib/perl5/site_perl/5.X.Y/. There should be very little, if any, files in that directory and its subdi-
rectories, excepting a number of .ph files;
o check that things work as they should;
o remove backup files from the package database.
Those will be /var/db/pkg/*/+CONTENTS.bak;
o that's all.
COPYRIGHT AND LICENSE
Copyright 2005 by Anton Berezin
"THE BEER-WARE LICENSE" (Revision 42)
<tobez@FreeBSD.org> wrote this module. As long as you retain this
notice you can do whatever you want with this stuff. If we meet some
day, and you think this stuff is worth it, you can buy me a beer in
return.
Anton Berezin
NO WARRANTY OF ANY KIND, USE AT YOUR OWN RISK.
HISTORY
The first version of this utility was not bundled with perl package on FreeBSD. It was dumber than the current version in several impor-
tant areas. It was faster.
CREDITS
Thanks to Mathieu Arnold for discussion.
SEE ALSO perl(1).
perl v5.8.9 2009-04-13 PERL-AFTER-UPGRADE(1)