ls -t1 | head -n 1 will give me the latest updated file so I want to tail that latest updated file in shell. How do I do that?
Asked
Active
Viewed 1,451 times
0
Stephen Kitt
- 411,918
- 54
- 1,065
- 1,164
KhalDrogo
- 11
- 2
1 Answers
2
One possible solution is to open a subshell for the command you want to run and add the result of the command as the parameter of tail:
tail "$(ls -t1 | head -n 1)"
Tamas H.
- 90
- 6
-
Cool, Its works. Thank you – KhalDrogo Jun 06 '19 at 08:39