Results 1 to 2 of 2

Thread: Create file add text to it in one command

  1. #1
    Join Date
    Oct 2007

    Create file add text to it in one command

    Create file, add text to the file in one command

    open a terminal window type:

    echo "The text you want added to a new file" >> the_file_name
    so simply put --
    use echo command with quotes around the text " " then the >> tells the text to be put into a file name.

    Nice way to create a quick note - or make a super simple bash script.

    I use it this when i create a junk account on 10min mail so i dont forget the user name and password.

    Example: I just created the account on website bartsimpson with a password of 12345678: Now i want to quicky make a text file with that info in it.

    echo "Site name user: bsimpson password: 12345678" >> forum_account.txt
    Now you have a file w/ this info in it. SIMPLE AS PIE

  2. #2
    Join Date
    Apr 2006
    Ubuntu Development Release

    Re: Create file add text to it in one command

    Another way to do it is to use cat:

    cat > filename
    Run it, type the text you want to put into the file, then hit Ctrl-C to save & quit.


Posting Permissions

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