if you are reading a file in a perl script, and want to exclude some part of it (header and trailer) from processing, then there is no need to invoke an external program such as egrep. you can exclude whatever part you want to with the help of perl systax. something like:
or better yet,
next skips to the following iteration. It does not return a useful value, and especially not a list containing a line you don't want to skip.
In case you want the current line in a variable, the diamond operator <F> puts the current input line in $_, not in @F (in scalar context). chop, print, and the regex matching operators etc. all operate on $_ by default, i.e. unless you specify another variable to use.
In list context, <F> returns a list containing all the (remaining) input lines from the file handle. Here's an example of using list context:
That is, grep the list of lines returned by <F>, picking out the ones which don't match the regex, and print them.
@F is only used if you have autosplit (-a option) in which case it contains the fields that the line was split into (on whitespace, unless you override it with the -F option).
Last edited by era; 06-19-2008 at 04:04 AM..
Reason: Explain when @F is useful, too
I have been searching and trying to come up with an awk that will perform the following on a
converted text file (original is a pdf).
1. Since the first two lines are (begin with) text they are removed
2. if $1 is a number then all text is merged (combined) into one line until the next... (3 Replies)
Greetings All,
I would like to find all occurences of a pattern and delete a substring from the all matching lines EXCEPT the first. For example:
1234::group:user1,user2,user3,blah1,blah2,blah3
2222::othergroup:user9,user8
4444::othergroup2:user3,blah,blah,user1
1234::group3:user5,user1
... (11 Replies)
Hi
I have stored a command output in an array like below
@a = `xyz`;
actually xyz comnad will give the output like this
tracker
date
xxxxxxx
xxxxxxx
---------------------
1 a
2 b
----------------------
i have stored the "xyz" output to an... (3 Replies)
Hi,
I'm not a expert in shell programming, so i've come here to take help from u gurus.
I'm trying to tailor a csv file that i got to make it work for the LOAD FROM command.
I've a datatable csv of the below format -
--in file format
xx,xx,xx ,xx , , , , ,,xx,
xxxx,, ,, xxx,... (11 Replies)
Dear All,
I have multiple files having number of records, consist of more than 10 columns some column values are duplicate and i want to remove these duplicate values from these files.
Duplicate values may come in different files.... all files laying in single directory..
Need help to... (3 Replies)
Can anyone tell me what could be the solution to following :
I have one .txt file which contains some "seed" information. This seed may appear multiple time in the file so what I want do is if this seed appears again in the file then that line should be removed.
Please provide the script code... (4 Replies)
Can anyone tell me what could be the solution to following :
I have one .txt file which contains some seed information. This seed may appear multiple time in the file so what I want do is if this seed appears again in the file then that line should be removed.
here is the contents of .txt... (5 Replies)