[NTLUG:Discuss] Scripting help

Dennis Kaptain dkaptain at yahoo.com.mx
Tue Apr 28 09:37:58 CDT 2009





> 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

You are missing the file name you want to look in.

grep 'the' FileToLookIn |  wc > thecount.txt

DK


      ¡Obtén la mejor experiencia en la web! Descarga gratis el nuevo Internet Explorer 8. http://downloads.yahoo.com/ieak8/?l=mx



More information about the Discuss mailing list