- grep command
Description :- its comes from g/re/p (globally search regular expression and print)
it is used as one of the most used command under unix
Usage:-- Find count of matching words
grep -c “queue” sanj_ms1.log”
this will find the number of occurence of queue word in the file sanj_ms1.log - Showing particular number of lines from the file after the matching word
grep -C 2 “queue” “sanj_ms1.log” - Different variant of grep command
- pgrep is the command to give the process id for a supplied process argument
pgrep -if java - grep -i do case insensetive search
this searches for the given string/pattern case insitively. So it matches all the words wether occuring in lower or uppercase
grep -i “string” FILE - zgrep is used to search for particular string under zip files
zgrep -iw “less” “filename.txt.gz
- pgrep is the command to give the process id for a supplied process argument
- Find count of matching words
- SCP command:- SCP command or secure copy is used for transferring of files to remote machine or transfer the files between two remote machines it uses the SSH protocol
syntax/examples can be reffered @ http://www.hypexr.org/linux_scp_help.php - Find command :- This command is widely used for searching of files across the system using required parameters
- Finding files 5 days older
find /path/to/files* -mtime +5 -exec rm {} \;- 1st argument is path to the files
- 2nd argument is -mtime specify the number of days old that file is
+5 will fetch files which are 5 days older - 3rd argument is -exec allow to pass command which needs to be executed on the result like rm {} \;
- Find the files ignoring case
- find -iname *.txt
- Find files as per the size its in bytes
- find . -size +1000c -exec ls -l {} \;
- find -szie +1000c -size -50000c -printing
- Finding files 5 days older
- netstat -tulpn | grep –color :80
- to extract the tarball
- untar -xvf filename.tar -C /tmp/dirname
- Finding file between two dates/timestamps
- find . -type f -newermt 2010-10-07 ! -newermt 2014-10-08
returns a list of files that havve timestamps after 2010-10-07 and before 2014-10-06 - Find files 15 minutes ago until now:
- find . -type f -mmin -15
Returns list of files that have timestamps after 15 mins ago but before now
- find . -type f -mmin -15
- Find files between two timestamps
- find . -type -newermt “2014-10-08 10:17:00” ! -newermt “2014-10-08 10:53:00”
returns files with timestamps between 2014-10-08 10:17:00 and 2014-10-08 10:53:00
- find . -type -newermt “2014-10-08 10:17:00” ! -newermt “2014-10-08 10:53:00”
- find . -type f -newermt 2010-10-07 ! -newermt 2014-10-08
- Export command examples
- export | grep ORACLE
declare -x ORACLE_BASE=”/u01/app/oracle”
declare -x ORACLE_HOME=”/u01/app/oracle/product/10.2.0″
declare -x ORACLE_SID=”med”
declare -x ORACLE_TERM=”xterm”
- export | grep ORACLE
- View the content of the file without unziping it
- unzip -l jasper.zip
Length Date Time Name -------- ---- ---- ---- 40995 11-30-98 23:50 META-INF/MANIFEST.MF 32169 08-25-98 21:07 classes_ 15964 08-25-98 21:07 classes_names 10542 08-25-98 21:07 classes_ncomp
- unzip -l jasper.zip
- FTP Commands
- ftp IP/hostname
ftp> mget *.html - ftp> mls *.html
/ftptest/features.html
/ftptest/index.html
/ftptest/othertools.html
/ftptest/samplereport.html
/ftptest/usage.html
- ftp IP/hostname
- CronTab command
- View corntab entry for specific user
crontab -u john -l - Schedule a cron job every 10 minutes
*/10 * * * * /home/ec2-user/check-disk-space
- View corntab entry for specific user