VC_work
VC_work

Reputation: 145

Grep in screen not saving output to logfile

I am trying to perform a very long grep scan trough my files. Because Screen will close after execution, I am trying to write to a log file to save the output of grep. The following command appeared:

 screen fgrep "needle" /mnt/Volume_volume/haystack/* >> /mnt/Volume_volume/log.txt

Unfortunately the log file is empty. What went wrong? Does the output of screen get saved instead of grep? How do I fix this?

Upvotes: 1

Views: 539

Answers (1)

ArturFH
ArturFH

Reputation: 1787

The command you wrote means: run screen fgrep "needle" /mnt/Volume_volume/haystack/* and append the result of this command to file /mnt/Volume_volume/log.txt. And screen displays noting on its output, so that's what you are getting in the log file.

If you really want to use screen, the proper command would be something like this:

screen bash -c 'fgrep "needle" /mnt/Volume_volume/haystack/* >> /mnt/Volume_volume/log.txt'

but I suspect simple:

nohup fgrep "needle" /mnt/Volume_volume/haystack/* >> /mnt/Volume_volume/log.txt &

would work for you too.

Upvotes: 5

Related Questions