I'm trying to create a .sh file that runs a process and then writes some of the logging output to a separate file. I have pretty much everything working except for a way to get cygwin to actually write to the file. Both of the following display a new cygwin window and seem to follow the log file but neither write to the output file:
cygstart tail -f ./logs/full-log.txt | grep --line-buffered "LOG_FILE:" > ./logs/lrp-log.txt
mintty tail -f ./logs/full-log.txt | grep --line-buffered "LOG_FILE:" > ./logs/lrp-log.txt
The following works, but I would like to incorporate this into my larger script so I need someway of getting it to run in the background so my script can continue on.
tail -f ./logs/full-log.txt | grep --line-buffered "LOG_FILE:" > ./logs/lrp-log.txt
CodePudding user response:
I suspect that
cygstart tail -f ./logs/full-log.txt | grep --line-buffered "LOG_FILE:" > ./logs/lrp-log.txt
means:
{ cygstart tail -f ./logs/full-log.txt; } | grep --line-buffered "LOG_FILE:" > ./logs/lrp-log.txt
i.e. you're running:
{ cygstart tail } | grep
instead of what you're trying to do:
cygstart { tail | grep }
If you're just trying to modify a shell script to put tail | grep
in the background then this is probably all you really need:
( tail -f ./logs/full-log.txt | grep --line-buffered "LOG_FILE:" > ./logs/lrp-log.txt; ) &