4

Is there a command to print the files in a directory in a single column without this additional info? Basically an ls command but with the output format of:

file1.txt
file2.txt
file3.txt

as opposed to :

file1.txt file2.txt 
file3.txt
7

You need the ls command -1 option.

ls -1 /dir

just to clarify. that is ls -(one) /dir; like the number.

from the man ls page:

 -1     list one file per line.  Avoid '\n' with -q or -b
0

You can use find. To list only files in the current dir, you can use -mindepth 1 -maxdepth 1.

$ find . -mindepth 1 -maxdepth 1
./file1.txt
./file2.txt
./file3.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.