I want to get the output of tail -f /var/log/apache2/error.log | grep “trace1” into a file. But tail -f /var/log/apache2/error.log | grep “trace1” > output.txt does not work, while the first command gives an output in my terminal window as expected. I guess it has to do with the follow-parameter, because if I omit the “-f”, the output file is
Tag: tail
Read last line of file after the file was modified
I have a problem with reading the last line of file in Linux Ubuntu. I have a file named auth.log and I’m trying to read it last line after new line was added (after file was modified). I know i need to use tail -1 /var/log/auth.log to get last line but I don’t know how to check the file every
Starting container process caused “exec: \”tail -f /dev/null\”: stat tail -f /dev/null: no such file or directory
Because I am trying to keep a container running I specified the “tail -f /dev/null” as command in the docker compose file: After I run docker-compose up I get the following error: ERROR: for serviceName Cannot start service serviceName: b’OCI runtime create failed: container_linux.go:348: starting container process caused “exec: “tail -f /dev/null”: stat tail -f /dev/null: no such file or
truncate shell command output from last line matching a string until EOF
I would like to truncate the output of a shell script and only print the part between the last line matching a string/regex and EOF. E.g when running letsencrypt certbot renew –post-hook “service apache2 reload; service nginx reload” I get something like Now what I want to have is everything after the last ——- line, so the desired result would
How to display a few line from the last few lines for a given number of files?
I have a folder with many different files. I want to display a specific line from the last 100 line of a list of files. So far I have tried both Grep and Tail but neither gave me exactly what I want: Example: the folder has the following files: file_1.txt file_2.txt file_3.txt other_file.txt other_file2.txt Content of file_n.txt is: line 88:
Get last 30 minutes from log file
I have a log file that contain logs as follows 1486307866.155 is the time in unix format with corresponds to 2017-02-05 07:17:46 (Format : Y-m-d H:i:s) I need a unix command that give me the logs within last 30 minutes in the following format and discarding any details that i don’t need. 2017-02-05 07:17:46|68.146.231.80|clients1.google.com:443 Answer Using GNU date and GNU
Tailing a file from where I left off before?
Suppose I have a file. I tail its last 10 lines and got some data. And the next time I come to tail, its length increases by 4. So I need to tail only that many lines to get data. Is there a simple command line for this? Like a mix of tail, wc, and grep? Answer If you save