Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

porting a bourne script to csh 1

Status
Not open for further replies.

noiz

IS-IT--Management
Apr 19, 2001
17
US
i have the following bourne script that lists all files adn directories in a given file. I have been asked to port it to the c shell and add functionality so that it will ask you to input names of directories and will then return a list of all their files and subdirectories.

My script:
#!/bin/sh
for i in *
do
if [ -d $i ]
then echo "$i is a sub directory"
else
echo "$i is a file "
fi
done

thanks zion
 
Not sure why someone would prefer C-shell over the Bourne shell, but this should be close to what you want.

#!/bin/csh

echo -n "Enter directory: "
set dir = $<
foreach i (`ls $dir`)
if ( -d &quot;$i&quot; ) then
echo &quot;$i is a sub directory&quot;
else
echo &quot;$i is a file &quot;
endif
end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top