I have this script, which will prompt for the relative or absolute path to the file and then swap whitespaces ' ' with '\ ' which works in Linux console. Substitution is done using the first sed command. After substitution I echo the path just for check and it is correct.
Then comes the second sed command which has to deal with the file for which I wrote the absolute path. Well it won't work... It looks like In the second command $drill_file isn't expanding. The weirdest thing is that it expands just fine outside the script... WOOT!?
#!/bin/bash
echo "Give relative or absolute path to the \"drill.TXT\" file:"
read drill_file_temp
drill_file=$(echo $drill_file_temp | sed -r 's/\s/\\ /g')
echo $drill_file
sed 's/\(^X[[:digit:]]*\)[[:digit:]]\(Y[[:digit:]]*\)[[:digit:]]/\1\2/' $drill_file
echo "Conversion finished."
sed: can't read /home/ziga/Dropbox/workspace/programi/eagle/projects/ISKRA/SLON\ -\ razsiritvena\ ploscica/v2.0/gerber/drill.TXT: No such file or directory
but If I execute sed manualy it works - I do it like this:sed 's/\(^X[[:digit:]]*\)[[:digit:]]\(Y[[:digit:]]*\)[[:digit:]]/\1\2/' /home/ziga/Dropbox/workspace/programi/eagle/projects/ISKRA/SLON\ -\ razsiritvena\ ploscica/v2.0/gerber/drill.TXT