Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 14132  / 2 Years ago, sat, may 21, 2022, 3:17:20

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
123" >> stdin && tail -1 stdin
abc
123

More From » bash

 Answers
6

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
123
' | tail -1



This will print 123.


[#28659] Sunday, May 22, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
quivedge

Total Points: 223
Total Questions: 116
Total Answers: 124

Location: Slovenia
Member since Wed, Apr 6, 2022
2 Years ago
;