My csh script is to validate types of the files. If it finds the sub directory t
ID: 3567013 • Letter: M
Question
My csh script is to validate types of the files. If it finds the sub directory then it should somehow recursively validate the files inside of the sub directory until there is no more sub directory left.
i was thinking this (cd $i;./proj3)
Anyone has any solution for this?
#!/bin/tcsh
foreach i (*)
if (-l $i) then
echo "$i is a symbolic link."
else if (-d $i) then
echo "$i is a directory."
(cd $i;./proj3)
else if (-p $i) then
echo "$i is a named pipe."
else if (-f $i) then
echo "$i is a ragular file."
else
echo "$i is unknown file."
endif
end
Explanation / Answer
function traverse() { foreach i (*) if (-l $i) then echo "$i is a symbolic link." else if (-d $i) then echo "$i is a directory." traverse $i else if (-p $i) then echo "$i is a named pipe." else if (-f $i) then echo "$i is a ragular file." else echo "$i is unknown file." endif end } function main() { traverse "$1" } main "$1"
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.