Page 1 of 1
Shell script
Posted: Mon Apr 21, 2014 4:20 pm
by archieoboyle
Hi,
Anyone have any idea how you could write a shell script that takes a string input from a user, asks for a file name and reports whether that string is present in the file?
Any help on this would be great!
Re: Shell script
Posted: Mon Apr 21, 2014 5:07 pm
by DeeJay
It might be cheating, but the command already exists - it is called grep.
Re: Shell script
Posted: Mon Apr 21, 2014 8:28 pm
by archieoboyle
Hahaha! thanks for the help, but need a shell script really.
thanks anyway!
Re: Shell script
Posted: Mon Apr 21, 2014 8:52 pm
by rpdom
archieoboyle wrote:Hahaha! thanks for the help, but need a shell script really.
thanks anyway!
But why can't you use grep in a shell script?
A shell script is just a series of ordinary commands with a few additions after all...
Re: Shell script
Posted: Mon Apr 21, 2014 9:04 pm
by DeeJay
Perhaps it is a homework question...
Re: Shell script
Posted: Tue Apr 22, 2014 9:44 am
by JCoomber
I see we've both hit rock bottom Archie, searching the exact question on google the day before its due in.
