I am attempting to write a script to list all the shebang lines in python files.
What I would like to do is
sudo bash -c 'for logf in $(find / -name "*.py"); do fgrep '#!/usr/bin' "$logf"; done'
This gives error bash: !/usr/bin': event not found
. I understand why, although the meaning of the error is unclear.
The trouble is I can't figure out how to pass a string to bash
which includes another string without command execution.
If I leave off the "#!" it works, but of course includes a number of other lines.
I have tried practically every combination of escape and string without success.
find
command:find / -name "*.py" -exec fgrep '#!/usr/bin' {} \; -print
– Ketan Feb 20 '16 at 03:45sudo
, and this works. As I am only using a single command there is no need for the bash command. – Milliways Feb 20 '16 at 04:14