Results 1 to 4 of 4

Thread: is there an echo in here?

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question is there an echo in here?

    Some times I want to append a file with multiple lines via echo.
    Im reading the man page for echo and see the \n option, but I cant get the syntax to give me what I want.
    Code:
    echo "#" Some User Defined Aliases \n GREP_OPTIONS='grep --color=always' > ~/ngo
    that gives me one line at the end of a file where I want 2 lines.
    ~Conradin~

  2. #2
    Join Date
    Jul 2010
    Location
    London
    Beans
    713
    Distro
    Ubuntu Gnome 17.04 Zesty Zapus

    Re: is there an echo in here?

    You need the -e flag, try this:

    Code:
    echo -e "# Some User Defined Aliases\nGREP_OPTIONS='grep --color=always'" > ~/ngo

  3. #3
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: is there an echo in here?

    In order for the '\n' to work you need to use the -e option. Also you need to put all between quotes:
    Code:
    echo -e "# Some User Defined Aliases \nGREP_OPTIONS='grep --color=always'" >> ~/ngo
    Note the use of '>>' instead of just '>' (so you append the lines instead of overwritten the file).

    Hope it helps.
    Regards.

  4. #4
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Talking Re: is there an echo in here?

    Thanks Jim! Thanks papibe!
    I got it now!
    ~Conradin~

Tags for this Thread

Bookmarks

Posting Permissions

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