Results 1 to 3 of 3

Thread: [RESOLVED] Bash SED command - Adding text to end of file

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2007
    Location
    England
    Posts
    61

    Resolved [RESOLVED] Bash SED command - Adding text to end of file

    Hey,

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

    Here is my current example:

    Code:
    #!/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!!
    Last edited by DonCash; Jun 27th, 2007 at 07:12 AM.

  2. #2
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: Bash SED command - Adding text to end of file

    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.

    Code:
    $ echo "username" >> users.txt
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2007
    Location
    England
    Posts
    61

    Resolved Re: Bash SED command - Adding text to end of file

    Your the man!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width