Write a shell script that
(1) ask for a file name from the user,
(2) check whether a file with the given file name exists in the current directory, and
(3) return the result to the user in a neat readable format.
#!/bin/ksh
while [ 1 ]
do
echo "Please enter a filename:\c"
read filename
if [ -z "${filename}" ];then
continue
elif [ -f "`pwd`/${filename}" ];then
more ${filename}
break
fi
done追问
while [ 1 ]
do
echo "Please enter a filename:\c"
read filename
if [ -z "${filename}" ];then
continue
elif [ -f "`pwd`/${filename}" ];then
more ${filename}
break
fi
done追问
大神,perl script会吗
Let there be a file, score.txt, which contains some integers. There is only one number per line, and the number of lines is unknown. Write a Perl script that
(1) read the intergers in score.txt,
(2) calculate the average,
(3) print the average on screen with proper format
i don't know perl.
but your request can process with shell very well.
温馨提示:答案为网友推荐,仅供参考