I had a question that was answered here: https://unix.stackexchange.com/questions/264925/awk-fs-with-back-slashes
After that I tried adding it to a .sh script that starts with:
#!/bin/bash
My Line:
category1Filenames=(\`find . -maxdepth 1 -type f |
gawk 'BEGIN { FS = "(\\\\./)|(\\\\.)" } ; { print $2 }' | sort -u\`)
And then I print the output using:
for genericFilename in ${category1Filenames[@]}; do
printf "%s\n" $genericFilename
done
But this gives me the error:
gawk: cmd. line:1: warning: escape sequence `\.' treated as plain `.'
If I change the line to be:
category1Filenames=$(find . -maxdepth 1 -type f |
gawk 'BEGIN { FS = "(\\\\./)|(\\\\.)" } ; { print $2 }' | sort -u)
Then it works as expected.
I'm assuming that the problem was with using the back tick characters, but I don't understand why. Probably because I don't understand the behavior of ` vs ' vs ". If anyone can point me to documentation that can explain this behavior (maybe tldp) then it would be greatly appreciated.
gawksupposed to do? It would be much simpler to just iteratefor genericFilename in *; do [[ -f $genericFilename ]] || continue; ...; done.