Skip to content

Instantly share code, notes, and snippets.

@ShahriyarR
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShahriyarR/11180234 to your computer and use it in GitHub Desktop.
Save ShahriyarR/11180234 to your computer and use it in GitHub Desktop.
GREP usage
1. # Searching for a single whole word in file #
# Note: Case Sensitive search
grep "InnoDB" logfile.log
2014-04-22 15:36:22 1022 [Note] Shutting down plugin 'InnoDB'
2014-04-22 15:36:22 1022 [Note] InnoDB: FTS optimize thread exiting.
2014-04-22 15:36:22 1022 [Note] InnoDB: Starting shutdown...
2014-04-22 15:36:24 1022 [Note] InnoDB: Shutdown completed; log sequence number 1626077
2. # Searching and counting match in file #
grep "InnoDB" logfile.log | wc -l
4
3. # For case-insensitive search use -i option:
grep -i "InnoDB" logfile.log | wc -l
32
4. # Searching for number :
grep "256" logfile.log
2014-04-22 15:36:24 1022 [Note] Shutting down plugin 'sha256_password'
#############################################################################################
Metacharacter search:
1. InnoDB sozu ile biten setrler:
grep "'InnoDB'$" logfile.log
2014-04-22 15:36:22 1022 [Note] Shutting down plugin 'InnoDB'
2. 2014 ile baslayan setrleri cixardir.
grep "^2014" logfile.log
3. Boyuk I kecen setrler:
grep "I.*" logfile.log
4. Terkibinde I kecen sonunda M olan ve setri sonlandiran Match-leri tap:
grep "I.*M'$" logfile.log
2014-04-22 15:36:24 1022 [Note] Shutting down plugin 'MyISAM'
2014-04-22 15:36:24 1022 [Note] Shutting down plugin 'MRG_MYISAM'
5. Her bir setrdeki herfi axtarir:
grep "[INNODB|MyISAM']" logfile.log
6. Complex Search:
grep "^2014-04-22" logfile.log | grep "InnoDB" | grep "'InnoDB'$"
2014-04-22 15:36:22 1022 [Note] Shutting down plugin 'InnoDB'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment