|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
using sed to append text to the end of each line
Anyone know how to use SED to append a comma to the end of each line
example: field1,field2,field3,field4 If i Cat /textfile ---- How can i append the end of /textfile with a comman? |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
echo 'a,b,c' | sed 's/$/,/' |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Works Great...Thanks for your help
|
|
#4
|
|||
|
|||
|
can u explain the syntax a little bit
about 'a,b,c' part |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Quote:
field1,field2,field3,field4 |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
I am not sure if I have to start another thread or request for an answer in the same thread..
Just wondering how we can append tabs at the end of each line... Data: field1, field2, field3, field4 1 2 3 4 5 Append tab on field3 and field4 for the first row..and Append tab on field4 for the second row. Please advise... Madhu |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Not quite sure what you're saying, but assuming you have a datafile that contains:
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 and you want it formatted as you've shown, you could do: awk '{print $1, $2"\n"$3, $4, $5"\n\n"}' <datafile> to get: 1 2 3 4 5 1 2 3 4 5 etc. The above could also be accomplished with "awk '{printf}'". I can't see the usefulness of adding tabs to the end of each line unless you plan to paste a file to this one, but you can do: sed 's/$/[press TAB button here]/' datafile > newfile |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| find a certain line and append text to the end of the line | peachclift | Shell Programming and Scripting | 2 | 12-19-2011 03:10 PM |
| Append text to end of every line | spacebase | Shell Programming and Scripting | 4 | 09-13-2011 06:45 PM |
| append each line with text | dvah | Shell Programming and Scripting | 2 | 03-10-2011 12:40 PM |
| Append text to end of line on all lines | giles.cardew | Shell Programming and Scripting | 5 | 11-26-2010 09:10 AM |
| sed - append text to every line | jgrogan | UNIX for Dummies Questions & Answers | 3 | 02-01-2010 07:06 AM |
|
|