&2 as function parameter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chella
    New Member
    • Mar 2007
    • 51

    &2 as function parameter

    Hi Experts,

    In a UNIX shell script a function is called with the parameter &2.

    f_check &2

    Please help me to understand what does the above call do.
    what does &2 mean there?

    Thanks in Advance,
    Chella
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    &1 represent the file descriptor for standard output
    &2 represent the file descriptor for standard error


    e.g.

    ls 2>&1 > temp.txt

    here standard error is duplicated as standard output (2>&1)
    So everything will be redirected to temp.txt

    for more information see
    man bash
    look for redirection
    or search for &1

    Correct me if I am wrong

    Comment

    Working...