When fd shows no files [til/cli]

I’m a big fan of fd and use it as a part of my dev workflow as it’s way easier than find.
I’ve used it to convert files on the fly for ingest, specifically converting xlsx to csv en mass.
This is the command I was running:
$ fd . -e xlsx -x sh -c “in2csv ‘{}’ > ‘{.}’.csv”

This finds all the files that end with xlsx (using -e) and executes (-x) a shell command that passes the full filename {} to in2csv (part of the csvkit tools) and outputs to the basename {.} with .csv appended.
Except I found that this wouldn’t work in certain situations. At first I thought it was because I had spaces in my filenames, but then remembered: [fd] ignores patterns from your .gitignore, by default.
Since xlsx files aren’t required in my git repo they’re ignored. So this TIL is more to make sure I don’t forget, to ignore the ignore file -I is required.
$ fd . -I -e xlsx -x sh -c “in2csv ‘{}’ > ‘{.}’.csv”

Simples.


This content originally appeared on remy sharp's b:log and was authored by remy sharp's b:log

I'm a big fan of fd and use it as a part of my dev workflow as it's way easier than find.

I've used it to convert files on the fly for ingest, specifically converting xlsx to csv en mass.

This is the command I was running:

$ fd . -e xlsx -x sh -c "in2csv '{}' > '{.}'.csv"

This finds all the files that end with xlsx (using -e) and executes (-x) a shell command that passes the full filename {} to in2csv (part of the csvkit tools) and outputs to the basename {.} with .csv appended.

Except I found that this wouldn't work in certain situations. At first I thought it was because I had spaces in my filenames, but then remembered: [fd] ignores patterns from your .gitignore, by default.

Since xlsx files aren't required in my git repo they're ignored. So this TIL is more to make sure I don't forget, to ignore the ignore file -I is required.

$ fd . -I -e xlsx -x sh -c "in2csv '{}' > '{.}'.csv"

Simples.

Originally published on Remy Sharp's b:log


This content originally appeared on remy sharp's b:log and was authored by remy sharp's b:log


Print Share Comment Cite Upload Translate Updates
APA

remy sharp's b:log | Sciencx (2021-05-21T11:39:58+00:00) When fd shows no files [til/cli]. Retrieved from https://www.scien.cx/2021/05/21/when-fd-shows-no-files-til-cli/

MLA
" » When fd shows no files [til/cli]." remy sharp's b:log | Sciencx - Friday May 21, 2021, https://www.scien.cx/2021/05/21/when-fd-shows-no-files-til-cli/
HARVARD
remy sharp's b:log | Sciencx Friday May 21, 2021 » When fd shows no files [til/cli]., viewed ,<https://www.scien.cx/2021/05/21/when-fd-shows-no-files-til-cli/>
VANCOUVER
remy sharp's b:log | Sciencx - » When fd shows no files [til/cli]. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/21/when-fd-shows-no-files-til-cli/
CHICAGO
" » When fd shows no files [til/cli]." remy sharp's b:log | Sciencx - Accessed . https://www.scien.cx/2021/05/21/when-fd-shows-no-files-til-cli/
IEEE
" » When fd shows no files [til/cli]." remy sharp's b:log | Sciencx [Online]. Available: https://www.scien.cx/2021/05/21/when-fd-shows-no-files-til-cli/. [Accessed: ]
rf:citation
» When fd shows no files [til/cli] | remy sharp's b:log | Sciencx | https://www.scien.cx/2021/05/21/when-fd-shows-no-files-til-cli/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.