I am attempting to write some some bash shell script (for the first time) to perform a few sequential actions (some copy, encrypt, upload, and simple logic checks) and I am struggling to work with the strings find is returning as they have special characters /\*)'(" and spaces.
I have seen suggestions to fix this using printf %q but I haven't been able to figure out the correct bash syntax.
Here is an excerpt of how I'm trying to change the strings:
#!/bin/sh
find "/upload" -type f |
while read -r path; do
fixedpath=printf %q "$path"
fixedpath=printf '%q' "$path"
fixedpath=printf '%q' $path
fixedpath=printf "%q" "$path"
fixedpath="printf %q $path"
fixedpath="printf '%q' $path"
fixedpath=$(printf '%q' $path)
echo $path >> list.txt
echo $fixedpath >> list.txt
done
exit 0
I could think of another 6-12 ways to write the printf function as well but I think you get the point, which one do I need to have a valid path returned that I can use to pass as an argument to other commands?
I am working on Ubuntu 16.