Skip to main content

Posts

Showing posts from July, 2015

Useful K shell commands and examples

Description Command Example How to get date in YYYYMMDDhhmmss format                          date +%Y%m%d%H%M%S                                 date +%Y%m%d%H%M%S 20150701164849        How to get hostname uname -n How to unzip and untar a file gunzip -c filename | tar -xvf - How to check if a file is non zero size if [ -s file ] How to check if a variable is empty  if [  -z file] How to check if a directory is present if [  -d file] How to check if a file is present if [  -f file] How to extract file name from path  echo filename | sed -e's/.*\///' # echo "/opt/app/tmp/pom.xml" | sed -e's/.*\///' pom.xml How to zip a file  cat $file |  gzip -c > $FILENAME How to retrieve return status from a shell $CTI/common/shells/SendToETL.sh TOPO $FILENAME RC=$? echo "Return status = $RC" How to run a command on a remote server ssh -l user hostname '. ./.profile;echo $JAVA_HOME