PDA

Click to See Complete Forum and Search --> : [RESOLVED] Bash SED command - Adding text to end of file


DonCash
Jun 27th, 2007, 07:28 AM
Hey,

I'm using the Unix SED command to try and add text to the end of a file.

Here is my current example:



#!/bin/bash

sed "s/./username/" users.txt



This adds 'username' to the beginning of every line in the users.txt file.

Example:


username john1
username mary2
username hiller3


How can I make it so that it adds this just once at the very bottom of the file?

Desired output:


john1
mary2
hiller3
username


Cheers for your help!! :duck:

tr333
Jun 27th, 2007, 08:00 AM
Don't use sed for this. If you want to add a single line to the end of the file, then use cat or echo to append to the file.

$ echo "username" >> users.txt

DonCash
Jun 27th, 2007, 08:11 AM
Your the man! :thumb: