Use grep command line

1.  Use grep to filter command line history

history | grep 'text'

 

2. Search text in all file of folder

grep -rnw '/path/to/folder/' -e 'text-to-search'
  • -r or -R is recursive,
  • -n is line number, and
  • -w stands for match the whole word.
  • -l (lower-case L) can be added to just give the file name of matching files.

 

3. Find files with name

find | grep "name_file"

 

4. Search texts with no contain char

grep(/^abc(?!e).*/)

Ex:

array = [“abcdx”, “abcex”, “abcfx”]

array.grep(/^abc(?!e).*/) => [“abcdx”, “abcfx”]

Advertisements