LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash store last line from displayed text output in a variable (https://www.linuxquestions.org/questions/programming-9/bash-store-last-line-from-displayed-text-output-in-a-variable-519719/)

carl0ski 01-16-2007 04:25 AM

Bash store last line from displayed text output in a variable
 
Hi i wont to use Mplayers auto crop detect feature and save the outpu to a variable

mplayer dvd:/// -vf cropdetect

output
Code:

[CROP] Crop area: X: 0..703  Y: 0..303  (-vf crop=704:304:0:0).0 0
[CROP] Crop area: X: 0..703  Y: 0..303  (-vf crop=704:304:0:0).0 0
[CROP] Crop area: X: 0..703  Y: 0..303  (-vf crop=704:304:0:0).0 0
[CROP] Crop area: X: 0..703  Y: 0..303  (-vf crop=704:304:0:0).0 0
[CROP] Crop area: X: 0..703  Y: 0..303  (-vf crop=704:304:0:0).0 0
[CROP] Crop area: X: 0..703  Y: 0..303  (-vf crop=704:304:0:0).0 0

i've trimmed it down with this

mplayer dvd:/// -vf cropdetect|cut -d '(' -f 2|cut -d ')' -f 1|grep crop|tail

output
Code:

-vf crop=704:304:0:0
-vf crop=704:304:0:0
-vf crop=704:304:0:0
-vf crop=704:304:0:0
-vf crop=704:304:0:0
-vf crop=704:304:0:0
-vf crop=704:304:0:0
-vf crop=704:304:0:0
-vf crop=704:304:0:0

i hope to get only 1 of these lines stored as a variable

raskin 01-16-2007 04:38 AM

tail -1
will leave only last line of piped text

var=$(command)
will store command output


All times are GMT -5. The time now is 10:25 AM.