Linux Commands




cp -R SRCFOLDER DESTFOLDER/  --copy folder

Cp file destination  -- copy a file

#Remove lines with containing specific text

sed -i '/pattern to match/d' ./infile


#renaming the file

Mv oldfilename newfilename


# send email

echo 'Body of mail .' | mailx -s 'subject of mail ' -a  /pathtotheattachment   mailid

du -hs *|sort -h  --> size in sorting order


tar -zcvf consumer.gz   /home/kolguk01/consumer  -- Gunzip folder
Rm -rf   --- remove folder


Check IP address of Linux server
/sbin/ifconfig

Remove files  older than 14 days

/usr/bin/find  /home/kolguk01/rpcache/mongo*.txt  -mtime  +14  -type f -exec rm {} \;


Replace a string

:%s/pattern/replace/
/g for all at once


Convert Windows text file to Unix file

--we do it by removing the character "\r"
Od -c filename | head -- to check if it has windows characters
cat cfit_ucc_account_full.txt | tr -d '\r' > cfit_ucc_account_new.txt

Remove whitespaces in vi

:%s/\s\+$//e

Sort Results in a table

cat BISNZDWP_0329_grm.rpt | sort -n -k 5 | tail  -20

Deleting Files

find /the/dir/to/start/in -type f -mtime +365 -ls -exec rm -f -- {} \;

Delete directories older than 30 days

find /buvol2/BISPRDDB/Netezza/NZ31652-H1/EDWP^C  -type d -ctime +30  -exec rm -rf -- {} \;

Transfer files through SCP

scp -r iomysql@dfwlnpmysql-02:/u04/mysdata/3309 /u04/mysdata/3309

Grep Multiple words

grep  '151.138.12.251\|151.138.12.252\|151.138.12.24\|151.138.12.27' /var/log/mongodb/mongod.log | grep "connection accepted" | wc -l

Comments

Popular posts from this blog

Netezza Commands

MS SQL Server Tips