新手unix shell script debugging help!# Unix - 噫吁兮,危乎高哉
j*n
1 楼
#!/bin/sh
# show script
if [ "$1" ]
if [ -d $1 ]
then
ls $1
if [ -f $1 ]
then
cat $1
else echo "File does not exist!"
fi
else
echo "you must give an argument"
fi
大家帮我看看这个程序哪里有问题?原题目是
2) Write a modified version of the show example script (the first example of
the if-statement given above), which prints out the message "File does not
exist" if the user gives a name which isn't a file or directory, and the
message "You must give an argument" if the user doesn't give an argument to
the program.
# show script
if [ "$1" ]
if [ -d $1 ]
then
ls $1
if [ -f $1 ]
then
cat $1
else echo "File does not exist!"
fi
else
echo "you must give an argument"
fi
大家帮我看看这个程序哪里有问题?原题目是
2) Write a modified version of the show example script (the first example of
the if-statement given above), which prints out the message "File does not
exist" if the user gives a name which isn't a file or directory, and the
message "You must give an argument" if the user doesn't give an argument to
the program.