I often want to edit the files resulting from find or fd like so:
fd myfile | my_script
In my script, vim would be run with all the files from STDIN as arguments like vim "myfile1" "myfile2". The arguments need to be individually double-quoted since they may include spaces & other special characters.
I've tried the following:
files=""
while IFS=$'\n' read -r line; do
files="$files $line"
done
file $files
The example should run file with the resulting file names as arguments. This kinda works, except having white spaces in the file names break it, and I've tried quoting the variables multiple ways with no success.
How can I run a command with newline-separated inputs as arguments with spaces?