LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   script to get a part of line from a file (http://www.linuxquestions.org/questions/programming-9/script-to-get-a-part-of-line-from-a-file-552697/)

mystical dervish 05-09-2007 04:38 PM

script to get a part of line from a file
 
Hello
I have a directory of several text files formatted as follwoing
[25.8376] [32.1000] B: xab~ir $uw fiy Eindak >axbaAr
[2.8376] [12.1000] B: xab $uw Gde Ginda >qwaAd
[100.8376] [200.1000] A: xab~ir $gd fhg Qwerak AssbaAr .
it appears that it has three parts seperated by \t tab,I want to get only the last part (red) of line and so on for whole file then all files
putting them in one file as output file formated as a words seperated by spaces

would you please help me to write a script to do that ??
thanx a lot
MD

drawde83 05-09-2007 06:17 PM

Code:

sed 's/^.*\t//' filename(s) > file to save to

ghostdog74 05-09-2007 06:24 PM

Code:

awk 'BEGIN{FS=": "}{ print $2 }' file* > outfile

mystical dervish 05-10-2007 03:10 AM

Quote:

Originally Posted by drawde83
Code:

sed 's/^.*\t//' filename(s) > file to save to


thank you its running

mystical dervish 05-10-2007 03:12 AM

Quote:

Originally Posted by ghostdog74
Code:

awk 'BEGIN{FS=": "}{ print $2 }' file* > outfile

thank you
but It doesnt result out !

ghostdog74 05-10-2007 05:30 AM

Quote:

Originally Posted by mystical dervish
thank you
but It doesnt result out !

Code:

# awk 'BEGIN{FS=": "}{ print $2 }' file
xab~ir $uw fiy Eindak >axbaAr
xab $uw Gde Ginda >qwaAd
xab~ir $gd fhg Qwerak AssbaAr .


druuna 05-10-2007 06:15 AM

Hi,

@ghostdog74: Shouldn't this:
FS=": "
be
FS=":\t"

The OP stated that fields are tab separated.

mystical dervish 05-11-2007 02:57 AM

Quote:

Originally Posted by druuna
Hi,

@ghostdog74: Shouldn't this:
FS=": "
be
FS=":\t"

The OP stated that fields are tab separated.


exactly !!!
thank you all


All times are GMT -5. The time now is 11:10 AM.