Re: [opensuse] bashscripting (?) help in working with text files
- From: "Theo v. Werkhoven" <theo@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 22 Jan 2008 00:26:18 +0100
Mon, 21 Jan 2008, by physwalker@xxxxxxxxx:
Hello List!
Through many pains I got the text file with some data and for plotting
purposes I need to separate it into files... with minimal knowledge on bash
scripting I was thinking maybe you could help me to figure that out... (I
tried to sort that out by hand, but then realised it will probably take a
month...)
I have special lines in my text file so, I'd love to be able to script
something like this
read through lines
if come to the string "bla bla bla"{
take the number after ": " on that string and put in file
named "something"...
Can be done in different ways, of course.
With grep and cut:
grep "bla bla bla" file |cut -d: -f2 >> something
With awk:
awk -F: '/"bla bla bla"/ {print $2}' file >>something
with Bash:
OLDIFS=$IFS
IFS=:
while read Line;do
set -- $Line
case $1 in
"bla bla bla") echo $2 >>something ;;
esac
done <file
IFS=$OLDIFS
Theo
--
Theo v. Werkhoven Registered Linux user# 99872 http://counter.li.org
ICBM 52 13 26N , 4 29 47E. + ICQ: 277217131
SUSE 10.3 + Jabber: muadib@xxxxxxxxxxxxxxxx
Kernel 2.6.22 + See headers for PGP/GPG info.
Claimer: any email I receive will become my property. Disclaimers do not apply.
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
- Follow-Ups:
- Re: [opensuse] bashscripting (?) help in working with text files
- From: Sergey Mkrtchyan
- Re: [opensuse] bashscripting (?) help in working with text files
- References:
- [opensuse] bashscripting (?) help in working with text files
- From: Sergey Mkrtchyan
- [opensuse] bashscripting (?) help in working with text files
- Prev by Date: Re: [opensuse] Why are there not more using Linux?
- Next by Date: Re: [opensuse] Why will not FireFox stay at the same font size?
- Previous by thread: [opensuse] bashscripting (?) help in working with text files
- Next by thread: Re: [opensuse] bashscripting (?) help in working with text files
- Index(es):
Relevant Pages
|