mercredi 23 juillet 2014

find + mv


find ./ -name "*.logfile" | xargs -i mv '{}' /my/really/great/implementation_scripts/log_directory/


(cf : http://bturnip.com/weblog/?p=248 )

or : 
find ./ -name "*.logfile" -exec  mv '{}' /my/really/great/implementation_scripts/log_directory/ \;

Test dir var (eval shell)



 Test if the given variable contains a valid directory. If not, exit. (This uses the eval function of the shell)
testdirvar () {
    tmp=$1
    if [ -d "${!tmp}" ] ; then
        echo "${tmp}=${!tmp} (variable ${tmp}: directory exists)"
    else
        echo "!!! ${tmp}=${!tmp} is not a directory (variable ${tmp}) !!!"
        exit
    fi
}