Results 1 to 5 of 5

Thread: Running command in background

  1. #1
    Join Date
    Sep 2013
    Beans
    2

    Running command in background

    Hi Everybody,
    could you please tell me why the following command doesn't release terminal:
    find / filename > findout &

    I expected the command to release my terminal and redirect output to file findout.
    Instead the output was still displayed on the terminal and I didn't get the command prompt.

    Thanks
    Klim

  2. #2
    Join Date
    Mar 2011
    Beans
    144
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Running command in background

    Quote Originally Posted by klim2 View Post
    Hi Everybody,
    could you please tell me why the following command doesn't release terminal:
    find / filename > findout &

    I expected the command to release my terminal and redirect output to file findout.
    Instead the output was still displayed on the terminal and I didn't get the command prompt.

    Thanks
    Klim
    Code:
    find / | grep filename &> findout &
    &> redirects all to findout,
    i personally use pipe grep for looking for filename but you can also use
    Code:
    find / -name "filename"

  3. #3
    qamelian's Avatar
    qamelian is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Feb 2005
    Location
    Nova Scotia, Canada
    Beans
    1,580
    Distro
    Ubuntu Development Release

    Re: Running command in background

    To release the terminal, enclose the entire command in parentheses:
    Code:
    (find / filename > findout &)

  4. #4
    Join Date
    Sep 2013
    Beans
    2

    Re: Running command in background

    @qamelian, not sure what I did wrong but the parentheses didn't help. I still got the output sent to the terminal, not findout file.

    @3246251196, thanks! the following command did the trick:

    find / -name "filename" &> findout &

    What is interesting that only one background process was started. I still can't explain to myself why it works.
    Is it documented somewhere?

  5. #5
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    I/O redirection

    There is only one process running, it is "find". The &> redirects both stdout and stderr to the same file. You can have more I/O streams than that if you set it up explicitly, but by default you have stdout and sterr for your programs' output.

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
  •