Wednesday, June 29, 2016

UNIX Commands

Shell Commands
=============

ls *.tar.gz*|wc -l         # Count

cp -r FILE_NAME/DIRECTORY_PATH     # Copy  e.g., " cp -r Scripts /c/my_dir/my_proj "

cp -r * FILE_NAME/DIRECTORY_PATH     # Copy_all e.g., " cp -r * /c/my_dir/my_proj "

rm *.gz           # Remove files

rm -rf DIR_NAME         # Remove DIR with sub-contents

cd ../AU                    # go directly to AU Folder

ls -d */ OR ls -ltr -d */           # list only directories

find . -maxdepth 1 -type f                 # list only files in current directory

find . -maxdepth 1 -type f > shivam.txt   # print output in a file

find . -type d -name "HK_SIT"     # search for a directory, ".(dot)" means current dir

ls -d HK_*                     # show all dir's starting with HK_

tar -xvf filename                   # untar files

$?                       # returns the status of the last finished command.                    Status 0 tells you that everything finished w/o error.

if [ $val -eq $? ]                   # $val extract the value that is hold by the val

grep 'abc_xyz' test.txt |cut -d, -f2   # search for the string "abc_xyz" inside                    test.txt & fetch 2nd field as ouput i.e, f2

tar -tvf file_name |grep '.xcl' | wc -l   # get count without untar

:1,$d                     # ':' colon command (moves the cursor                              to the bottom), The 1,$ is an indication of which                    lines the following command (d) should work on.

:4,$-2d                     # leaving only the first 3 and last 2 lines, deleting the rest.

:%d                       # delete all text from file

grep 'SG/AU/SIT' *.*                 # search string in all files of current directory

echo 'MY_PASSWORD_2016'|base64                 # ENCRYPT

echo 'Q1NBX0NUTF9JE1Cg' |base64 -d              # DECRYPT

mailx  -s "[$value_1|$value_2|$value_3] "TEXT......" $v_grp_name is corrupted" $GEM_XCL_EMAIL <<EOM



No comments:

Post a Comment