Hello,
I'm works on Ubuntu server
My goal : I would like to read file line per line, but i want to started at the end of file.
Currently, I use instructions :
while read line;
do
COMMAND
done < /var/log/apache2/access.log
But, the first line, i don't want this. The file is long so, i would like to start at the end of file.
I'm available for your questions.
Thanks.
RudiC
2
Did you consider the tac
command?
1 Like
Aia
3
Perhaps, modifying what you have already:
tac /var/log/apache2/access.log | while IFS= read line; do
COMMAND using line
done
1 Like
If tac
is not available try:
tail -r file
or
sed '1!G;h;$!d' file
See here:
2 Likes
Aia
5
You are in Ubuntu which by default it has tac, but in case you do not want to use it, you may use the other alternatives.
Let's give you one more:
perl -e 'print reverse <>' /var/log/apache2/access.log | while IFS= read line; do
COMMAND using line
done
1 Like
Thanks for your answer.
I don't know "tac". He works with my script. GOOD
Bye.
---------- Post updated at 12:08 PM ---------- Previous update was at 12:07 PM ----------
solved