=============================================================
# Let us suppose that we want to see if the files in folder1 are also in folder2.
cd folder1
for i in `ls`
do
if [ if ../folder2/$i]
then
#do nothing because I want to know the non-existing files
present=1
else
echo "folder2/"$i file is missing
ls -l $i >> /tmp/size_of_the_impacted_files
fi
# end of job
# This shell_script is copywrited, only Yordan friends may use it
=============================================================
=====================================================================
=========================================================================
=========================================================================
======================================================================
#!/bin/sh
hostname=server56
if [ -n `ssh $hostname 'ls /usr/local/file 2>/dev/null'` ]; then
echo file exists
else
echo file doesn't exist
fi
=======================================================================
# Let us suppose that we want to see if the files in folder1 are also in folder2.
cd folder1
for i in `ls`
do
if [ if ../folder2/$i]
then
#do nothing because I want to know the non-existing files
present=1
else
echo "folder2/"$i file is missing
ls -l $i >> /tmp/size_of_the_impacted_files
fi
# end of job
# This shell_script is copywrited, only Yordan friends may use it
=============================================================
# Check the number of input parameters. If two parameters are given go ahead, else exit
if [ $# -eq 2 ]
then
FROMDIR=$1
TODIR=$2
else
echo "Usage: script.sh fromdir todir"
exit
fi
# Validate from_directory
if [ ! -d "${FROMDIR}" ]
then
echo "Directory ${FROMDIR} does not exist!!"
exit
fi
# Validate to_directory
if [ ! -d "${TODIR}" ]
then
echo "Directory ${TODIR} does not exist!!"
exit
fi
cd ${FROMDIR}
for i in `find . -type f`
do
if [ ! -f ${TODIR}/$i ]
then
cp $i ${TODIR}/$i
fi
done
==============================================================================
diff <(ssh paehowup2303 'find /home/x136873 -type f') <(ssh njros1up2303 'find /home/x136873 -type f')
=====================================================================
dest=path/to/destination cd /path/to/source for file in $( ls ) do if [ -d $fname ] then continue fi if [ -f $dest/$fname ] ; then cp $fname $dest/${fname}1 else cp $fname $dest/${fname} fi done
=========================================================================
#!/bin/bash FILE=$1 if [ -f $FILE ]; then echo "File $FILE exists" else echo "File $FILE does not exists" fi
=========================================================================
======================================================================
#!/bin/sh
hostname=server56
if [ -n `ssh $hostname 'ls /usr/local/file 2>/dev/null'` ]; then
echo file exists
else
echo file doesn't exist
fi
=======================================================================
No comments:
Post a Comment