Let's say ls -t returns:
1
2
3
4
5
6How can I skip the first 3 results? So the result is only:
4
5
6I am aware I can run ls -t | head -3 but that will simply take the first 3 lines, but I need to skip the first 3 lines.
1
2
3 2 1 Answer
Use tail:
ls -tq | tail -n+4Please note that I added -q option to ls to prevent issues with newlines in filenames. While this might be the default for ls output to terminal, it is not the default when piped.
Also note, that this is okay for visual output but not for scripting, as files with newlines won't work, because newlines get replaced by ?.
In general you should avoid parsing ls.