Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add text at end of each line

Status
Not open for further replies.

jawon

Programmer
Feb 6, 2003
31
0
0
US
I have a pipe-delimited flat file (say, myfile.txt) that looks something like...

2004-03-16 | user | action

Within a shell script, I'd like to add some text at the end of each line so that the resulting file would look like...

2004-03-16 | user | action | 1

What is the easiest way to accomplish this?
 
cat myfile.txt | awk '{print $0 " | 1"}'



I love deadlines. I like the whooshing sound they make as they fly by - Douglas Adams
 
Or avoiding the UUOC*

awk '{print $0 " | 1"}' myfile.txt > myfile2.txt

CaKiwi

* Useless Use Of Cat

CaKiwi
 
We should form SPUUOC*: The Society for the Prevention of UUOC.

* pronounced "spwock
 
And the sed way:
sed 's!$! | 1!' /path/to/input >output

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Can't be useless if it does the job. Unnecessary perhaps!!

I love deadlines. I like the whooshing sound they make as they fly by - Douglas Adams
 
it simply does it in the useless way.

UUOC

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top