This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes help on awk or sed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "help on awk or sed" Watch "help on awk or sed" New topic
Author

help on awk or sed

vshrivastava
Greenhorn

Joined: Jan 11, 2002
Posts: 1
Hi to all,
I need to relese a script by today itself. please help me to do this.
I have a big file lets say 65 thousand lines. it is a tab seperated text file. i need to add one more columne at the end of every line ( tab seperated). the value of that column is the first column of the first line.
example:
Inputfile:
NY^hhhhh^hhhhh^kkkkk^gggg
hhh^jjjjj^9999^44444
888^hhhh^443444^hhhhhh
Output file
NY^hhhhh^hhhhh^kkkkk^gggg^NY
hhh^jjjjj^9999^44444^NY
888^hhhh^443444^hhhhhh^NY
here '^' represent tab character.

please help me ASAP.
vivek S.
viveks@fox.com
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

awk is the better tool for this. sed works with lines as addresses; awk can recognize words on the line more effciently.

That's all you need. Then turn on the execute bit for this file and run it as a program:
$ rex {data_file}
That should do it.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: help on awk or sed
 
Similar Threads
convert string to number
SOAP,WSDL,UDDI
Java code help!
scanning an input file
jsp table