• Re: Misunderstanding sed command

    From red floyd@2:250/1 to All on Thu May 11 02:05:15 2023
    On 5/9/2023 8:31 AM, Michael Wood wrote:
    sed is acting on stdout, but the errors get written to stderr.  You can re-direct stderr to stdout, to get the sed to work using:
    du -d 1 2>&1 | sed '/du:/d'


    OP doesn't want the stderr. So the previously discussed

    du -d 1 2> /dev/null | sed '/du:/d'

    is the proper answer here.

    --- MBSE BBS v1.0.8.3 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From William Unruh@2:250/1 to All on Thu May 11 23:43:25 2023
    On 2023-05-11, red floyd <no.spam.here@its.invalid> wrote:
    On 5/9/2023 8:31 AM, Michael Wood wrote:
    sed is acting on stdout, but the errors get written to stderr.  You can
    re-direct stderr to stdout, to get the sed to work using:
    du -d 1 2>&1 | sed '/du:/d'


    OP doesn't want the stderr. So the previously discussed

    du -d 1 2> /dev/null | sed '/du:/d'

    is the proper answer here.

    Except all of the lines with du: in them are from stderr, not stdout.
    so
    du -d 1 2> /dev/null
    would be enough. However there might be other lines in stderr that he
    wants to see. Certainly his post says he only wanted to get rid of the
    lines with du: in them.

    --- MBSE BBS v1.0.8.3 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From red floyd@2:250/1 to All on Fri May 12 23:08:11 2023
    On 5/11/2023 3:43 PM, William Unruh wrote:
    On 2023-05-11, red floyd <no.spam.here@its.invalid> wrote:
    On 5/9/2023 8:31 AM, Michael Wood wrote:
    sed is acting on stdout, but the errors get written to stderr.  You can >>> re-direct stderr to stdout, to get the sed to work using:
    du -d 1 2>&1 | sed '/du:/d'


    OP doesn't want the stderr. So the previously discussed

    du -d 1 2> /dev/null | sed '/du:/d'

    is the proper answer here.

    Except all of the lines with du: in them are from stderr, not stdout.
    so
    du -d 1 2> /dev/null
    would be enough. However there might be other lines in stderr that he
    wants to see. Certainly his post says he only wanted to get rid of the
    lines with du: in them.

    Agreed.

    --- MBSE BBS v1.0.8.3 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)