Re: [opensuse] bashscripting (?) help in working with text files



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



Relevant Pages

  • [opensuse] bashscripting (?) help in working with text files
    ... scripting I was thinking maybe you could help me to figure that out... ... if come to the string "bla bla bla"{ ... " on that string and put in file ... Maybe any references where I can read that, without going through "bash ...
    (SuSE)
  • Re: ZwQueryValueKey
    ... PUCHAR pBla = "Bla"; ... > Don't use a string constant to initialize ANSI_STRING ... >> This is still indicating a buffer overrun. ... >>> RtlUnicodeStringToAnsiString(), which are structures, not pointers to ...
    (microsoft.public.development.device.drivers)
  • Re: Preventing Word from displaying the list of macros
    ... you can't use acronyms to call a string. ... it's a bit akward as all the entries would have the same beginning ... "Department of national bla bla bla.." ... problem 2 (using short acronyms to call autotext entries). ...
    (microsoft.public.word.vba.general)
  • Re: output of system() call
    ... i read that systemcall can be used to invoke other ... >program (shell scripts etc). ... >if mytest.sh has echo "bla" in it. ... you don't need the bash, ...
    (comp.lang.perl.misc)
  • Re: Arrays: Hilfe =?ISO-8859-15?Q?f=FCr_Anf=E4nger_wird_ben=F6tigt?=
    ... die einen String komplett groß ... Das könnte Dir bei deinem zweiten Problem behilflich sein. ... Du kannst es aber halt auch mit ner Schleife rausbekommen, ... Bla bla = new Bla; ...
    (de.comp.lang.java)