Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote