Computer Science, asked by pragyachakraborty14, 10 months ago

Write a command to display the list of last 3 files present in the current directory.

Answers

Answered by bollapallysandeep
55

Answer:

ls | tail -n3

Explaination

we can get by using pipe and tail command. Using ls, we get the list of files and these files are now input to tail command(tail -n3) that prints the last 3 lines from the input.

Answered by ankhidassarma9
0

Answer:

ls  -lht  |  tail  -n 3

where 3 is the number of output files from the end.

-l outputs in a list format

-h makes output human readable .

-t sorts output and places most recently modified file first.

Explanation:

  • The ls command of Linux, is used to list files or directories in Linux or other Unix-based operating systems.
  • The ls command also accepts some flags that are additional information and helps to change how files or directories are listed in the terminal.
  • The tail command, as the name implies, print the last N  data of the given input. By default tail command prints the last 10 lines of the specified files. If more than one file name is provided then data from each file is precedes by its file name.

Similar questions