One: grep 'ASCII text'
returns not only the file name, but also the type of the file itself; you need to process the output to return only the file name
Two: chmod
does not accept arguments from STDIN, which is what you're trying to do with the pipe |
. You'll have to either use xargs
or wrap the above in a for
loop
That said, here are two solutions for you:
Solution #1: With Pipes
file * | awk '/ASCII text/ {gsub(/:/,"",$1); print $1}' | xargs chmod -x
Solution #2: With for-loop
for fn in $(file * | awk '/ASCII text/ {gsub(/:/,"",$1); print $1}'); do chmod -x "$fn"; done
Pick yer poison :-)