andrian Aug 15, 2016 #1 Hi, please help me. How get string line use tail command from variable in shell script file. For example: Code: #!/bin/sh a=`timeout 60 tail -f /var/log/mpd.log | grep "Device not configured"` b=`tail -n 1 $a` #this string is error because "$a" not file!
Hi, please help me. How get string line use tail command from variable in shell script file. For example: Code: #!/bin/sh a=`timeout 60 tail -f /var/log/mpd.log | grep "Device not configured"` b=`tail -n 1 $a` #this string is error because "$a" not file!
youngunix Aug 16, 2016 #2 Is this " ..."$a" not file!" the actually error that you get when running the script?
SirDice Administrator Staff member Administrator Moderator Aug 16, 2016 #3 I'm sure there are tons of better ways to do this: Code: b=`echo $a | tail -n 1`