[plug] Simple bash scripting problem

Richard Meyer meyerri at westnet.com.au
Mon Oct 10 18:35:49 WST 2005


On Mon, 2005-10-10 at 18:29 +0800, Richard Meyer wrote:

ME AGAIN I PASTED THE WRONG OUTPUT - 

Here is the REAL output


> richard1 at Selous:~/project> sh test.sh "*.c"
> fred d.c kids.c prob1.c prob2.c prob3.c prob4.c prob5.c prob6.c prob7.c prob8.c prob9_1.c
> ./kids.c
> ./fred d.c
> ./prob9_1.c
> ./prob1.c
> ./prob2.c
> ./prob3.c
> ./prob4.c
> ./prob5.c
> ./prob6.c
> ./prob7.c
> ./prob8.c



Bloody hell, such a simple problem, and so much finger trouble ....


> 
> GOT IT..................................
> 
> ls output
> 
> 
> > richard1 at Selous:~/project> ls -l *.c
> > -rw-r--r--  1 richard1 users    0 2005-10-10 18:04 fred d.c     <===== note spaces
> > -rw-r--r--  1 richard1 users 2956 2005-07-29 12:02 kids.c
> > -rw-r--r--  1 richard1 users   51 2005-07-16 10:59 prob1.c
> > -rw-r--r--  1 richard1 users  331 2005-07-16 10:59 prob2.c
> > -rw-r--r--  1 richard1 users  209 2005-07-16 10:59 prob3.c
> > -rw-r--r--  1 richard1 users  324 2005-07-16 10:59 prob4.c
> > -rw-r--r--  1 richard1 users  165 2005-07-16 10:59 prob5.c
> > -rw-r--r--  1 richard1 users  141 2005-07-16 10:59 prob6.c
> > -rw-r--r--  1 richard1 users  156 2005-07-16 10:59 prob7.c
> > -rw-r--r--  1 richard1 users  362 2005-07-16 14:17 prob8.c
> > -rw-r--r--  1 richard1 users  749 2005-07-16 14:47 prob9_1.c
> 
> shell prog 
> 
> > richard1 at Selous:~/project> cat test.sh
> > #!/bin/bash
> > echo $@
> > for file in "$@"; do
> >         find . -name "$file" -print
> > done
> 
> output
> 
> 
> > richard1 at Selous:~/project> find . -name "*.c" -print
> > ./kids.c
> > ./fred d.c
> > ./prob9_1.c
> > ./prob1.c
> > ./prob2.c
> > ./prob3.c
> > ./prob4.c
> > ./prob5.c
> > ./prob6.c
> > ./prob7.c
> > ./prob8.c
> 
> OK, the order is different, but what the heck - exercise for the student
> is to change the find command to do what you want ....
> 
> -- 
> Richard Meyer <meyerri at westnet.com.au>
> Cutting the space budget really restores my faith in humanity.  It
> eliminates dreams, goals, and ideals and lets us get straight to the
> business of hate, debauchery, and self-annihilation.
>                 -- Johnny Hart
> 
> Linux Counter user #306629
> 
> _______________________________________________
> PLUG discussion list: plug at plug.org.au
> http://www.plug.org.au/mailman/listinfo/plug
> Committee e-mail: committee at plug.linux.org.au
-- 
Richard Meyer <meyerri at westnet.com.au>




More information about the plug mailing list