I've got a file called Files.txt
having following content:
TestApp/Resources/Supporting Files/main.m
TestApp/Resources/Supporting Files/AppDelegate.h
TestApp/Resources/Supporting Files/AppDelegate.m
I am pulling file and directory names as following and passing them to another process.
files=$(cat Files.txt)
for item in $files ; do
dn=$(dirname $item)
printf $item
printf "\n"
printf $dn
printf "\n\n"
# passing to another process
done
However, this is getting me this:
TestApp/Resources/Supporting
TestApp/Resources
Files/main.m
Files
TestApp/Resources/Supporting
TestApp/Resources
Files/AppDelegate.h
Files
TestApp/Resources/Supporting
TestApp/Resources
Files/AppDelegate.m
Files
What I need is this:
TestApp/Resources/Supporting Files/main.m
TestApp/Resources/Supporting Files
TestApp/Resources/Supporting Files/AppDelegate.h
TestApp/Resources/Supporting Files
TestApp/Resources/Supporting Files/AppDelegate.m
TestApp/Resources/Supporting Files
I tried prefixing space with \
in Files.txt
as:
TestApp/Resources/Supporting\ Files/main.m
and with %20
as:
TestApp/Resources/Supporting%20Files/main.m
with no luck!