[NTLUG:Discuss] Scripting help

jm jm5379 at gmail.com
Tue Apr 28 08:38:44 CDT 2009


i'm not sure of the sequence but i believe your 2nd version would be
correct ( grep 'the' | wc > thecount.txt )
once you supply a source file where all the "the's" are stored, such as

grep the <source_file> | wc > thecount.txt

i don't believe the quotes will be necessary



On Tue, Apr 28, 2009 at 9:34 AM, Dennis Myhand <dmyhand at ednaisd.org> wrote:
> I am trying to show my hardware students some of the things that cane be
> done from the command line once they get Linux installed on their
> hardware.  I was trying to show how to write a basic bash script that
> would grep 'the' from a text file, run each instance of 'the' through wc
> and redirect that output to another file called thecount.txt.  I
> originally thought that:
>
> #!/bin/bash
>
> grep 'the' > thecount.txt | wc
>
> would work, but that does not seem to do the trick.  So I changed the
> order a bit and tried:
>
> #!/bin/bash
>
> grep 'the' | wc > thecount.txt
>
> This does not seem to work either.  I remember doing something like this
> in school (10 years and 3 moves back) but I cannot seem to locate my
> notes.  What am I missing here, besides the notes, I mean?  What would
> be the best way to write this script?  Thanks, Dennis in Victoria
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
>



-- 
since this is a gmail account, please verify the mailing list is
included in the reply to addresses



More information about the Discuss mailing list