I'm trying to run a small gawk script which will run certain shell commands using
system(). I want to get the file list with
find and run the script like that:
find <arguments> -printf "%f\n" | script.awk
The problem is that these files have special characters such as spaces, quotes and parentheses in them. For example:
$ ls 'Aujourd'\''hui C'\''est Toi (Orchestral).flac'
I tried all sorts of quotes like the following:
I get all sorts of errors, some of these errors are from
sh -c and some are from
Is there a way to pass the record
$0 or any other variables from the gawk script to a shell command with out encountering all of theses problems?
Note: I know it could have been easier to just rename the files temporarily but I find it more challenging to avoid it.
None of the suggested answers solved my problem so here is a more specific description of the problem: I'm trying to run a command which uses 2 awk variables. Examples:
If I run:
system("metaflac --show-tag=ARTIST \""FILE"\"")
I don't get an error because I quote
FILE and because it doesn't contain double quotes it goes OK.
But if I run:
system("metaflac --set-tag=ARTIST="AWK_VAR_WITH_ARTIST_VALUE" "\"FILE\")
Even when I quote it, I get an error by
metaflac that the flac file was not found. When reading the error message, I see the file name was split into separate words.