I know head gives you the beginning section of a file. But in this case, I'm trying to go through my source control and find every file that has a shebang line. And I'm failing to get results when I use head. What am I doing wrong?
When I say doesn't work, i mean it returns nothing. But I know it should've returned something.
Works, but slow!
find . | awk '!/((\.jpeg)|(\.jpg)|(\.html)|(\.png))$/ {print $0; }' | xargs grep "#!"
Doesn't Work
find . | awk '!/((\.jpeg)|(\.jpg)|(\.html)|(\.png))$/ {head $0; }' | xargs grep "#!"
Update As @devnull pointed out, and easily verified by googling. I'll list here for reference: Awk Commands
if ( conditional ) statement [ else statement ]
while ( conditional ) statement
for ( expression ; conditional ; expression ) statement
for ( variable in array ) statement
break
continue
{ [ statement ] ...}
variable=expression
print [ expression-list ] [ > expression ]
printf format [ , expression-list ] [ > expression ]
next
exit
awkmuch but it just occurred to me thatprintis internal. Throw up an answer if you're sure.headisn't anawkcommand.awkhas a specific, and very limited set of commands... shame on me I'll have to add it to my reading list.systemfunction which can be used to run arbitrary programs/commands, although generally there are better solutions than to use this.