Bash: Find files, export as CSV
I needed to find/list files in a folder with some attributes (size) for a customer who needs those information in excel… Oh dear. Let’s do it:
# find . -type f -printf '"%h","%f","%s"\n'
-printf takes a format-string. In my example:
- %h is the files folder
- %f is the filename itself
- %s is the filesize in bytes
- every piece of information is separated by a single comma
- and enclosed by doublequotes
This gave me a nice CSV-representation i just had to throw into OpenOffice in order to save it as Excel.