[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

808ercise: Shell Golf



Shell Golf rules apply.

Problem Description:

The environment is Linux or other Unix-like environment with the usual 
assortment of commonly found POSIX/GNU tools.

Your shell is Bash 2.05.

Your current directory is an arbitrary directory location. This implies a 
parent and one or more child directories. 

There is a large (arbitrary) collection of files in the directory.
Some of the files are executable binary data files. Others are not.
Some of the files are text-based executable scripts. Others are not.

Your mission, should you choose to accept it, is to identify all script 
files (as identified by the 'file' command) in that directory and to 
display the resulting grep of only those script files for the phrase 
'that pays' in them. The grep must display the source filename and the 
matching lines, just as if multiple files were being searched.

You may use the commands 'file' and 'grep'.
No other commands external to the shell may be used.

The solution must be expressed as a single command pipeline.

A solution is disqualified if a test case can demonstrate any of:
1. The command produces any output other than the matching grep output.
2. Performs grep searches of any file other than script files.
3. Does not perform a grep search of all script files.
4. Does not locate an instance of the phrase 'that pays' in a script file.

My solution weighs in at 100 characters. I believe 92 may be possible.

Any challengers?

Mike808/

---------------------------------------------
http://www.valuenet.net



-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.