How to ls command to output one entry per line [macOS/Linux/Bash]


If you just use the ls command without any options the output will be displayed in one line,

Example:
code2care@mac ~ % ls
Desktop		Downloads	Movies		Pictures
Documents	Library		Music		Public

If you want the output to be displayed one entry per line, use -1 (number 1) optional parameter with the ls command.

Example on macOS terminal:
code2care@mac ~ % ls -1
Desktop
Documents
Downloads
Library
Movies
Music
Pictures
Public
ls command to show one entry per line
ls command to show one entry per line

If you want to see more details about the directories and files you can make use of ls -l (lowercase letter l) command,

Example:
code2care@mac ~ % ls -l
total 0
drwx------+  5 code2care  staff   160 Jan 10 14:10 Desktop
drwx------+  3 code2care  staff    96 Jan  2 23:03 Documents
drwx------+  3 code2care  staff    96 Jan  2 23:03 Downloads
drwx------@ 68 code2care  staff  2176 Jan  6 20:29 Library
drwx------   4 code2care  staff   128 Jan  2 23:33 Movies
drwx------+  6 code2care  staff   192 Jan  5 22:37 Music
drwx------+  4 code2care  staff   128 Jan  2 23:28 Pictures
drwxr-xr-x+  4 code2care  staff   128 Jan  2 23:03 Public
ls command with -l option output
ls command with -l option output
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap