Celeb Glow
news | March 21, 2026

Can ls output in CSV format with directory and file columns?

I need a recursive directory listing like ls -R, but in CSV format.

I want separate columns for the directory and filename.

1

2 Answers

ls cannot print data in CSV format, but find can, when given a custom output format:

find . -type f -printf '%h,%f\n'

%h denotes the directory part, %f the filename part. See the manual, especially the section about -printf format.

However, be aware that this won't work properly when your filenames have special characters or a , in them.

1

ls CAN list contents in csv format using ls -mand can do so recursively using ls -Rm

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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