It is currently Tue, 30 Nov 2021 17:06:56 GMT



 
Author Message
 help in learning how to do Bourne shell scripts then converting them to csh scripts
hope I am doing this right this time, so far I have struck out  2 times.
Sorry for being so stupid. This is a tough subject for me and it probably
seems pretty stupid to all you UNIX gurus I just don't know where to go for
help.


 Fri, 08 Oct 2004 08:39:22 GMT   
 help in learning how to do Bourne shell scripts then converting them to csh scripts
--(Once apon a time, in comp.unix.questions,)--
                --(Ida Pletz said it like only they can.)--

 if [ -f $1 ] ; then
          ls -f
      elif [ -d $1 ] ; then  
          ls -d
      else echo "syntax error"
 fi

No need for an "=" when checking for the existance of something. And
the flag should go in front of the thing we are testing for.

also lets change the else to be a little more discriptive
      else echo "Error: `basename $0`: No such file or dir: $1"

this is another case where it will help to read the man page for test
and "if" again and combine it with a little bit of echo.

again man test and this time we will use the builtin sh command "read"

if [ xxxxxxxxx ] ; then
   echo do you want to see $dir?
   read response
   if [ xxxxxxxx $response ] ; then
      ls $dir

man wc
to find out about counting.

--
+-(faux@fugozi)-(0.04|0.03|0.00)-(17:44|Sun Apr 21)-+ cat ~/.{sig,uin}
It's a damn poor mind that can only think of one way to spell a word.
        - Andrew Jackson
UIN=66618055



 Fri, 08 Oct 2004 08:56:16 GMT   
 help in learning how to do Bourne shell scripts then converting them to csh scripts

    This is better suited to comp.unix.shell than comp.unix.questions;
    Follow-ups set.

    You should read the ls man page; the -f and -d options do not do
    what you think they do.

    You will find answers to this in comp.unix.shell, in the thread,
    "How do I display current dir if no dir is given"

    This, also, is answered in the above-mentioned thread.

    Also, not mentioned in that thread, you might look at the -F
    option to ls.

--
        Chris F.A. Johnson                              bq...@torfree.net
        =================================================================
        c.f.a.john...@rogers.com                http://cfaj.freeshell.org
        c...@freeshell.org        http://members.rogers.com/c.f.a.johnson



 Fri, 08 Oct 2004 11:07:52 GMT   
 
   [ 3 post ] 

Similar Threads

1. help converting CSH shell scripts

2. HELP! bourne shell bug (setuid scripts)


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software