The script below was written to select files and convert a particular string to something other and replace that file. However, I came across some issues with filenames that contain spaces, any suggestions to get around this? Any other suggestions that may apply to this code would also be appreciated.
hi!!,
i am not clear whether the filename has spaces or the directory name has spaces.... U have written diferent things in the main body of post and the Title..
anyway.. i assume that the directory name has space..
its actually the directory name that contains the space.
The error first occurs with the dirname command. I got around that before by quoting specific things, however the find command dies if you are for example under a directory that contains a name with spaces.
ie /dir/spec/test/new\ test\ directory/script.sh
but the find command wont recognise the path, i tried doing something like this unsuccessfully ENVIRON=`pwd | sed s/\ /\\\\\ /g
i have tested by creating 3-4 levels of directory names with spaces inside the directories having spaces in names. and find works fine in all those levels just by puttting $ENVIRON in quotes.
Actually, I tried that before, but it didn't work running from the directory with the space in the directory name. But I just tried it again from the command line in a test directory and it worked.
Anyway, I tried it again adapting it to the script and it worked. I think the last time I tried I must have missed something else, being too complex or something else was at play.