tail output of program

12,449

You do not have to specify stdout as the output as it is natural. You would want to use a pipe char to pipe the output (stdout) to the tail utility.

You would want do to something like:

printf 'abc\n123\n' | tail -1

This will print 123.

Share:
12,449
HennyH
Author by

HennyH

Updated on September 18, 2022

Comments

  • HennyH
    HennyH over 1 year

    How do you use tail to get the last line outputted by a program. I've tried the following so far:

    echo `cmd` >> stdin && tail -1 stdin
    

    For instance:

    henry@henry-pc:~$ echo "abc\n123" >> stdin && tail -1 stdin
    abc\n123