This is a follow up to a question posted on SO.
I've written a script called
except which should print all filenames / directories except the ones given like so.
$ ls a b c d $ rm $(except b d) $ ls b d
The script I've written so far looks like this
shopt -s extglob shopt -s nullglob old_ifs=$IFS IFS='|' matches="!($*)" IFS=' ' printf '%s' $matches IFS=$old_ifs
This works more or less but the main problem is that printf doesn't seem to respect
IFS set to
It just prints them without a space between. If I instead use echo, it works (except for the added newline). But for compatibility reasons I want to use printf for this task. How can I achieve this? What am I doing wrong?
I also tried using the
%q modifier which also didn't result in the desired output.
printf '%q' $matches