test remote file if directory

Posted by soField on Stack Overflow See other posts from Stack Overflow or by soField
Published on 2010-06-09T13:24:05Z Indexed on 2010/06/09 13:32 UTC
Read the original article Hit count: 160

Filed under:
HOSTNAME=$1

#missing files will be created by chk_dir
for i in `cat filesordirectorieslist_of_remoteserver`
do

isdir=remsh $HOSTNAME "if [ -d $i ]; then echo dir; else echo file; fi"

if [ $isdir -eq "dir" ]
then

remsh $HOSTNAME "ls -d $i | cpio -o" | cpio -id
else

remsh $HOSTNAME "ls | cpio -o" | cpio -id
fi
done

i need simple solution for checking remote file is directory or file ? thanks

© Stack Overflow or respective owner

Related posts about unix