On Fri, May 03, 2024 at 06:59:37AM +0800, jeremy ardley wrote: > I have a need to get the full path of a file that has spaces in its name to > use as a program argument > > e.g. > > jeremy@client:~$ ls -l name\ with\ spaces > -rw-r--r-- 1 jeremy jeremy 0 May 3 06:51 'name with spaces' > jeremy@client:~$ realpath name\ with\ spaces > /home/jeremy/name with spaces
Looks good to me. > The spaces without quotes cause problems with subsequent processing. Then the subsequent processing has bugs in it. Fix them. > Can realpath or other utility return a quoted pathname? That would be extremely counterproductive. Do not look for kludges to work around your script's bugs. Fix the bugs instead. Start with <https://mywiki.wooledge.org/Quotes>.