How to copy specific content of a dynamic file to another flie
Hi Guys,
I want to copy a particular content of a dynamic file, which keeps on updating. Is there any way of doing it by using linux commands. |
There are several bash commands that will accomplish this. I would use grep. If the file to search is /var/log/messages and the search string is USB then the following command would copy all lines in /var/log/messages containing the letters USB to a file called output.txt.
Code:
grep USB /var/log/messages > output.txt |
You could try to look into inotifywait to set a watch on that file, and parse its contents with sed, awk or whatever each time it's modified.
A basic watch would be: Code:
inotifywait --monitor --even modify --format %w foo | \ |
Something like
tail -f firstfile >newfile and/or look at the 'tee' cmd |
All times are GMT -5. The time now is 10:46 PM. |