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

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
9
down vote
favorite
I need a recursive directory listing like ls -R, but in CSV format.
I want separate columns for the directory and filename.
command-line files ls
add a comment |Â
up vote
9
down vote
favorite
I need a recursive directory listing like ls -R, but in CSV format.
I want separate columns for the directory and filename.
command-line files ls
1
Close voters. This is asked and answered correctly.
â Elder Geek
10 hours ago
add a comment |Â
up vote
9
down vote
favorite
up vote
9
down vote
favorite
I need a recursive directory listing like ls -R, but in CSV format.
I want separate columns for the directory and filename.
command-line files ls
I need a recursive directory listing like ls -R, but in CSV format.
I want separate columns for the directory and filename.
command-line files ls
edited 11 hours ago
Martin Thornton
2,38531730
2,38531730
asked 13 hours ago
Shailey999
463
463
1
Close voters. This is asked and answered correctly.
â Elder Geek
10 hours ago
add a comment |Â
1
Close voters. This is asked and answered correctly.
â Elder Geek
10 hours ago
1
1
Close voters. This is asked and answered correctly.
â Elder Geek
10 hours ago
Close voters. This is asked and answered correctly.
â Elder Geek
10 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
9
down vote
ls cannot print data in CSV format, but find can, when given a custom output format:
find . -type f -printf '%h,%fn'
%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
Adding quotation marks can at least avoid producing an invalid CSV if a filename contains,:-printf '"%h","%f"n'.
â Bakuriu
2 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
9
down vote
ls cannot print data in CSV format, but find can, when given a custom output format:
find . -type f -printf '%h,%fn'
%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
Adding quotation marks can at least avoid producing an invalid CSV if a filename contains,:-printf '"%h","%f"n'.
â Bakuriu
2 hours ago
add a comment |Â
up vote
9
down vote
ls cannot print data in CSV format, but find can, when given a custom output format:
find . -type f -printf '%h,%fn'
%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
Adding quotation marks can at least avoid producing an invalid CSV if a filename contains,:-printf '"%h","%f"n'.
â Bakuriu
2 hours ago
add a comment |Â
up vote
9
down vote
up vote
9
down vote
ls cannot print data in CSV format, but find can, when given a custom output format:
find . -type f -printf '%h,%fn'
%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.
ls cannot print data in CSV format, but find can, when given a custom output format:
find . -type f -printf '%h,%fn'
%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.
answered 13 hours ago
PerlDuck
3,1101727
3,1101727
1
Adding quotation marks can at least avoid producing an invalid CSV if a filename contains,:-printf '"%h","%f"n'.
â Bakuriu
2 hours ago
add a comment |Â
1
Adding quotation marks can at least avoid producing an invalid CSV if a filename contains,:-printf '"%h","%f"n'.
â Bakuriu
2 hours ago
1
1
Adding quotation marks can at least avoid producing an invalid CSV if a filename contains
,: -printf '"%h","%f"n'.â Bakuriu
2 hours ago
Adding quotation marks can at least avoid producing an invalid CSV if a filename contains
,: -printf '"%h","%f"n'.â Bakuriu
2 hours ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1062566%2fcan-ls-output-in-csv-format-with-directory-and-file-columns%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password

1
Close voters. This is asked and answered correctly.
â Elder Geek
10 hours ago