data extraction between two characters

February 17, 2010 at 22:05:59
Specs: Linux i686
Hi,
how can i extract a data between two characters

input file is like

abc efg hig - 99.4% (16337276 kB) used
efg klm - 47.1% (7734968 kB) used
hij - 99.4% (16341464 kB) used
klm -93.7% (15394516 kB) used

output should be

99.4
47.1
99.4
93.7

thanks in advance


See More: data extraction between two characters

Report •

#1
February 18, 2010 at 08:56:39
I interpret that you want everything between the dash and the percentage sign. This is a way:

cut -d'-' -f2 < myfile | cut -d'%' -f1

Also, The GNU version of awk, i.e.gawk, found on most Linux distros supports mulitple field seperators. That version of awk should also solve the problem. When I get near my Linux system, I will try it out.


Report •

#2
February 18, 2010 at 15:07:17
nails and a few others are evil command line wizards. Able to leap tall buildings with a single line of code.

One thumbs up for him.


Playing to the angels
Les Paul (1915-2009)


Report •

#3
February 18, 2010 at 18:17:10
Thanks nails the code worked for me

Report •
Related Solutions


Ask Question