Unix shell script with pattern matching with Sed/Awk
$30-40 USD
Betales ved levering
I need a Shell script called ‘proc’ written in bash that accepts exactly 3 command line arguments.
The first argument is either a file or a directory name (if it is a directory, then the program must recursively apply each step that I will outline below to every subordinate file) The second argument is a file name. The third argument is the output file.
Proper checking must be done if the command line arguments do not exist or the files they specify cannot be opened or created.
Processing the files in arg1 is straightforward: If there is a word in arg2 that exists in arg1, then output the entire line and the line number to arg3 (output file). Matches are case sensitive. Substrings ARE outputed.
EXAMPLE:
Directory /home/john/work contains 1 file named Foo and 1 directory named Bar. Directory Bar has 2 files, named bar1 and the other named bar2. Contents of each file:
_Foo:_
The lazy man
Went to the store
To buy some bread.
_bar1:_
lazy
men sometimes
are strange
_bar2:_
super
Strange men
Go often to the market.
A2 is jark.
jark’s contents:
man
go
some
# super
Then, this command: ./proc /home/john/work /home/john/work/jark /home/john/work/output will create a file named ‘output’ with the following contents:
/home/john/work/Foo
1. The lazy man
3. To buy some bread
/home/john/work/Bar/bar1
3. men sometimes
/home/john/work/Bar/bar2
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
Must run on unix/linux with bash shell. Must use sed or awk for pattern matching
Prosjekt-ID: #3454693