Get last line of shell output as a variable

穿精又带淫゛_ 提交于 2019-12-01 02:29:31

Put the tail inside the capturing parens.

OUTPUT=$(exif ... | tail -1)

You don't need the double quotes here. I'm guessing that you tried

OUTPUT="$(exif ...) | tail -1"

Probably an old post to be answering now, but try using the -n flag (see tail --help) and wrap the command output using ticks.

OUTPUT=`exif ... | tail -n 1`

(user464502's answer did not work for me as the tail command does not recognize the parameter "-1")

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!