Mon, 21 Jan 2008, by [EMAIL PROTECTED]:

> 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: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to