Show the end of service.log and continue displaying new lines as they are appended.
Which command is appropriate?
tail -f follows a file after printing its end and waits for appended data, commonly until interrupted with Ctrl+C.
Detailed explanation
head -f service.logIncorrect. GNU head does not provide the requested follow behavior with -f.
less -n service.logIncorrect. less -n changes line-number handling and does not start follow mode.
tail -f service.logCorrect. tail -f service.log continues printing appended lines.
wc -l service.logIncorrect. wc -l counts the current lines once and exits.
Try it yourself
An example you can run in a temporary verification environment.
tail --help | grep -m1 -- '--follow'Expected result
--followに関するhelp行。長時間監視は開始しないKey points
- tail shows the end
- -f means follow
- Ctrl+C usually stops following
Notes
- Environment: GNU coreutils 9.x / help表示のみ
- Use small, disposable text streams when testing filters.
- Locale, encoding, and GNU/POSIX implementation details can affect edge cases.
Foundation review
Place the operation
tail -f is a long-running observation mode rather than a one-time snapshot.
Check the side effect
Use a temporary log and stop the watcher explicitly after appending a line.