Showing posts with label Linux-cmds. Show all posts
Showing posts with label Linux-cmds. Show all posts
Tuesday, August 23, 2016
find files with and without matching string in Linux
****************************************************************************
Find all files without string "successfully completed" in directory
****************************************************************************
find /home/oracle/test -type f | xargs grep -L "successfully completed"
****************************************************************************
Find all files with macthing string "successfully completed" in directory
****************************************************************************
find /home/oracle/test -type f | xargs grep -l -n "successfully completed"
Monday, March 14, 2016
script to check if the file exists
#!/usr/bin/ksh
## This is a simple script to check if the file exists in a dir or not
## Created by : Arvind Reddy
## This will prompt for
echo " file name please : "
read FILENAME;
export dataDir=/u01/app/oracle/dpump;
sourceFile=SCOTT.dmp;
cd /u01/app/oracle/dpump;
echo `pwd`
##Did we get a file?
if [ -e ${dataDir}/${sourceFile} ];then
echo "Found file !! "
else
echo " No file found !!! "
fi
## This is a simple script to check if the file exists in a dir or not
## Created by : Arvind Reddy
## This will prompt for
echo " file name please : "
read FILENAME;
export dataDir=/u01/app/oracle/dpump;
sourceFile=SCOTT.dmp;
cd /u01/app/oracle/dpump;
echo `pwd`
##Did we get a file?
if [ -e ${dataDir}/${sourceFile} ];then
echo "Found file !! "
else
echo " No file found !!! "
fi
Linux os level backup and cleanup cmds
REMOVE ALL FILES OLDER THAN 15 DAYS:
[oracle@Linux01 dpump]$
find /u01/app/oracle/dpump/*.dmp -mtime +15 -exec rm {} \;
GZIP ALL FILES OLDER THAN 15 DAYS: (This will make individual GZIP files)
[oracle@Linux01 dpump]$
find /u01/app/oracle/dpump/*.dmp -mtime +90 -exec gzip {} \;
MOVE FILES OLDER THAN 15DAYS
find /home/arvind -maxdepth 1 -iname "*.txt" -mtime -15 -exec mv {} /home/arvind/test1/ \;
COUNT FILES OLDER THAN 90 DAYS
find /u01/app/oracle/admin/adump/*.aud -mtime +90 | exec wc -l {} \;
TAR ALL FILES OLDER THAN 15 DAYS:
(This will make 1 TAR FILE With date format at end)
[oracle@Linux01 dpump]$
find /u01/app/oracle/admin/ORCL/adump/*.aud -mtime +90 | xargs tar -czvPf /u01/app/oracle/admin/ORCL/adump/ARCH_AUD_$(date +%F).tar.gz
[oracle@Linux01 dpump]$
find /u01/app/oracle/dpump/*.dmp -mtime +15 -exec rm {} \;
GZIP ALL FILES OLDER THAN 15 DAYS: (This will make individual GZIP files)
[oracle@Linux01 dpump]$
find /u01/app/oracle/dpump/*.dmp -mtime +90 -exec gzip {} \;
MOVE FILES OLDER THAN 15DAYS
find /home/arvind -maxdepth 1 -iname "*.txt" -mtime -15 -exec mv {} /home/arvind/test1/ \;
COUNT FILES OLDER THAN 90 DAYS
find /u01/app/oracle/admin/adump/*.aud -mtime +90 | exec wc -l {} \;
TAR ALL FILES OLDER THAN 15 DAYS:
(This will make 1 TAR FILE With date format at end)
[oracle@Linux01 dpump]$
find /u01/app/oracle/admin/ORCL/adump/*.aud -mtime +90 | xargs tar -czvPf /u01/app/oracle/admin/ORCL/adump/ARCH_AUD_$(date +%F).tar.gz
Wednesday, February 24, 2016
Convert all text in a file from UPPER to lowercase on LINUX
Convert all text in a file from UPPER to lowercase
To translate or delete characters use tr command. The basic syntax is:
Lets create a simple text file with mix of lower and upper case chars :
oracle@Linux01:[/u01/app/oracle/admin/bin] $ vi TGTGTG.txt
oracle@Linux01:[/u01/app/oracle/admin/bin] $ cat TGTGTG.txt
as This IS in Upper
Here I am passing the TGTGTG.txt as inprt and converting the output to lower case:
oracle@Linux01:[/u01/app/oracle/admin/bin] $ tr '[:upper:]' '[:lower:]' < TGTGTG.txt > output.txt
oracle@Linux01:[/u01/app/oracle/admin/bin] $ cat output.txt
as this is in upper
Here I am passing the TGTGTG.txt as inprt and converting the output to UPPER case:
oracle@Linux01:[/u01/app/oracle/admin/bin] $ tr '[:lower:]' '[:upper:]' < TGTGTG.txt > output_UP.txt
oracle@Linux01:[/u01/app/oracle/admin/bin] $ cat output_UP.txt
AS THIS IS IN UPPER
oracle@Linux01:[/u01/app/oracle/admin/bin] $
To translate or delete characters use tr command. The basic syntax is:
Lets create a simple text file with mix of lower and upper case chars :
oracle@Linux01:[/u01/app/oracle/admin/bin] $ vi TGTGTG.txt
oracle@Linux01:[/u01/app/oracle/admin/bin] $ cat TGTGTG.txt
as This IS in Upper
Here I am passing the TGTGTG.txt as inprt and converting the output to lower case:
oracle@Linux01:[/u01/app/oracle/admin/bin] $ tr '[:upper:]' '[:lower:]' < TGTGTG.txt > output.txt
oracle@Linux01:[/u01/app/oracle/admin/bin] $ cat output.txt
as this is in upper
Here I am passing the TGTGTG.txt as inprt and converting the output to UPPER case:
oracle@Linux01:[/u01/app/oracle/admin/bin] $ tr '[:lower:]' '[:upper:]' < TGTGTG.txt > output_UP.txt
oracle@Linux01:[/u01/app/oracle/admin/bin] $ cat output_UP.txt
AS THIS IS IN UPPER
oracle@Linux01:[/u01/app/oracle/admin/bin] $
Subscribe to:
Posts (Atom)