Printing the first 6 files in a current directory using the terminal

Advertisements

I am trying to work out how to use the terminal. Does anyone know how I can print the first 7 file names of a current directory? I am using:

ls

to print all of the files. How can I print the first 7? I hope this makes sense πŸ™‚

>Solution :

You can pipe it into head like this

ls | head -7

Leave a Reply Cancel reply