Hi Folks, A rather general question on scripting. I'm taking a file and using awk, removing the first column from it which consists of lines like this: 208A03860010237500300767698/00125.04.20050521770084998030132879550012 I then want to remove the 2nd and 3rd characters and dump them to a separate file (each extraction on a separate line) at which point uniq -c will be run on the file and the results emailed out. The question is does anyone have any idea on removing the 2nd and 3rd characters, I suspect I can use some kind of regular expression and piping the file through sed to expand everything out and then use awk again to remove the desired parts. However what I know of regex can be written in very large type on the back of a postage stamp. Any suggestions or different approaches gratefully received. Regards, Ben
Fri, 13 May 2005, by benh.suse@gmail.com:
Hi Folks,
A rather general question on scripting. I'm taking a file and using awk, removing the first column from it which consists of lines like this:
208A03860010237500300767698/00125.04.20050521770084998030132879550012
I then want to remove the 2nd and 3rd characters and dump them to a separate file (each extraction on a separate line) at which point uniq -c will be run on the file and the results emailed out.
The question is does anyone have any idea on removing the 2nd and 3rd characters, I suspect I can use some kind of regular expression and piping the file through sed to expand everything out and then use awk again to remove the desired parts. However what I know of regex can be written in very large type on the back of a postage stamp.
Any suggestions or different approaches gratefully received.
Easiest with 'cut -c 2-3' I think, unless I miss your point. Is the original file to be saved too, or just the extracted characters? Theo -- Theo v. Werkhoven Registered Linux user# 99872 http://counter.li.org ICBM 52 13 26N , 4 29 47E. + ICQ: 277217131 SUSE 9.2 + Jabber: muadib@jabber.xs4all.nl Kernel 2.6.8 + See headers for PGP/GPG info. Claimer: any email I receive will become my property. Disclaimers do not apply.
On 5/13/05, Theo v. Werkhoven
Easiest with 'cut -c 2-3' I think, unless I miss your point. Is the original file to be saved too, or just the extracted characters?
Perfect thankyou!! *Reflects on thesis advisors adivice to 'keep it simple stupid'* :) Best, Ben
On Friday 13 May 2005 11:00 am, Ben Higginbottom wrote:
Hi Folks,
A rather general question on scripting. I'm taking a file and using awk, removing the first column from it which consists of lines like this:
208A03860010237500300767698/00125.04.20050521770084998030132879550012
I then want to remove the 2nd and 3rd characters and dump them to a separate file (each extraction on a separate line) at which point uniq -c will be run on the file and the results emailed out.
The question is does anyone have any idea on removing the 2nd and 3rd characters, I suspect I can use some kind of regular expression and piping the file through sed to expand everything out and then use awk again to remove the desired parts. However what I know of regex can be written in very large type on the back of a postage stamp.
Any suggestions or different approaches gratefully received. AWK has a substring function. x=substr($1, 2,2); In this case, x will contain the string "08". $1 is the first word in the line, which would be the string you have above.
--
Jerry Feldman
participants (3)
-
Ben Higginbottom
-
Jerry Feldman
-
Theo v. Werkhoven