I have a simple bash script which outputs the total file size using 'du' However every time I pass a file that contains an apostrophe it presents me with a syntax error. So I'd like to know if there was a way to escape singlequotes without modifying the filenames. Preferably before diskusage processes them.
The code is:
du -chs {query}
I use Alfred to pass the files into the script. The application allows the user to escape a few characters but the single quote is not one of them.
Try wrap the file names in double quotes, that seems to work for me:
With a file named
hello'world
among a few others:Gives: