简体   繁体   中英

Possible to read the last line of a linux gnu-screen?

I'm trying to make a simple and reliable script, preferably in bash, that is executed every minute using crontab. The script simply has to read the contents of the last couple of lines of an open screen and store them as a var so that I can search for a sub-string. Does anyone know of an easy way to do this, thanks.

You can send the hardcopy command to the screen and read the last line using the tail command:

screen -X hardcopy "~/test.log"
tail -n1 ~/test.log

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM