Really need help for this C shell script [Archive] - C Board

PDA

View Full Version : Really need help for this C shell script


Unregistered
04-21-2002, 11:17 PM
a script must :

dis play time
display current directory
count all none hidden files
and count directories

must execute in any directory, and one dierectory only.


I write like this.. but it does not work. Try hard to fix but no clue. Need help!! just a homework project for beginner... :(


if ($#argv ==0 ) then
set dir ="."
else
set dir = $argv[1]
endif
if $1argv != 0 ) then
echo you must point to a directory "
echo Type "csh prog -h" for help
set "csh prog -h" = $argv2
if ($2argv == 0 ) then
echo specific directory for the program to execute such as : csh prog /billshare
echo *****end help***********
else
echo - n Date to day is\:
set d = `date`
echo $d[2] $d[3] $d[6]
echo -n Current dir\:
pwd
echo display non hidden flies\:
ls $dir
echo count all file in current directory\:
ls $dir |wc -l
echo Count the directories\:
ls -l $dir|grep -c ^d
end if

taps
04-22-2002, 04:39 AM
#!/bin/sh

date | cut -d ' ' -f 4
echo $PWD
echo "Number Of directories"
ls -l| grep -c ^d
echo "The list of Files"
ls -l| grep -v ^d