grep
Shell
Options Description
-c : This prints only a count of the lines that match a pattern
-h : Display the matched lines, but do not display the filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the pattern
-e exp : Specifies expression with this option. Can use multiple times.
-f file : Takes patterns from file, one per line.
-E : Treats pattern as an extended regular expression (ERE)
-w : Match whole word
-o : Print only the matched parts of a matching line,
with each such part on a separate output line.# EXAMPLE 1: look for any files (with names ending in ".c++") for the text "::MethodA("
grep "::MethodA(" *.c++
# EXAMPLE 2: display only the matching file names (not the row too) of the matches
grep -l "MethodA(" *.c++
# SYNTAX
# grep [optional-filters] "<your-string-to-search>" <files-to-search>
# OPTIONAL-FILTERS
# +--------+----------------------------------------------------------------------------+
# | OPTION | DESCRIPTION |
# +--------+----------------------------------------------------------------------------+
# | -e | pattern |
# | -i | Ignore uppercase vs. lowercase. |
# | -v | Invert match. |
# | -c | Output count of matching lines only. |
# | -l | Output matching files only. |
# | -n | Precede each matching line with a line number. |
# | -b | A historical curiosity: precede each matching line with a block number. |
# | -h | Output matching lines without preceding them by file names. |
# | -s | Suppress error messages about nonexistent or unreadable files. |
# | -x | |
# | -f | file: Take regexes from a file. |
# | -o | Output the matched parts of a matching line. |
# +--------+----------------------------------------------------------------------------+
Also in Shell:
- Title
- putty for ubuntu
- Category
- Shell
- Title
- powershell check if software is installed
- Category
- Shell
- Title
- Load key ".pem": bad permissions
- Category
- Shell
- Title
- ubuntu install git
- Category
- Shell
- Title
- how to make a .sh file executable
- Category
- Shell
- Title
- delete github repository curl
- Category
- Shell
- Title
- gats gatsby-plugin-offline
- Category
- Shell
- Title
- vim command to open a file
- Category
- Shell
- Title
- kill port ubuntu
- Category
- Shell
- Title
- git command to create a branch
- Category
- Shell
- Title
- npm list global packages
- Category
- Shell
- Title
- electron
- Category
- Shell
- Title
- whats up with docker compose and orphan containers
- Category
- Shell
- Title
- loop bash
- Category
- Shell
- Title
- linux generate file
- Category
- Shell
- Title
- driver hosts file
- Category
- Shell
- Title
- linux os update
- Category
- Shell
- Title
- wmv to mp4 ffmpeg
- Category
- Shell
- Title
- how to use curl command in ubuntu
- Category
- Shell
- Title
- ubuntu bluetooth not listed
- Category
- Shell
- Title
- git switch branch
- Category
- Shell
- Title
- maven install on mac os x
- Category
- Shell
- Title
- how to reset git branch to a certain commit.
- Category
- Shell
- Title
- special bash variables
- Category
- Shell
- Title
- stop docker container
- Category
- Shell
- Title
- Error: Node Sass does not yet support your current environment
- Category
- Shell
- Title
- download images from url terminal
- Category
- Shell
- Title
- how to install nvm in mac
- Category
- Shell
- Title
- how to install react router dom with typescript
- Category
- Shell
- Title
- git undo pushed commit
- Category
- Shell
- Title
- upgrade node version
- Category
- Shell
- Title
- Linux Mint reset xfce-panel
- Category
- Shell
- Title
- how to install and update git mac terminal
- Category
- Shell
- Title
- docker remove image
- Category
- Shell
- Title
- checking if a directory exists in bash
- Category
- Shell
- Title
- rename branch git
- Category
- Shell
- Title
- partially apply stash git
- Category
- Shell
- Title
- allow user root commands linux centos
- Category
- Shell
- Title
- Shell query displays all citizens with an age greater than or equal to 21
- Category
- Shell
- Title
- linux vim set tab to 4 spaces
- Category
- Shell
- Title
- manjaro network driver installed but not working
- Category
- Shell
- Title
- how to update pip in linux
- Category
- Shell
- Title
- gatsby transformer remark
- Category
- Shell
- Title
- use python shell with git bash
- Category
- Shell
- Title
- linux inhalt einer textdatei anzeigen
- Category
- Shell
- Title
- revert git add
- Category
- Shell
- Title
- install packages with pip from python
- Category
- Shell
- Title
- how to save environment variables ubuntu
- Category
- Shell
- Title
- change dns resolver linux
- Category
- Shell
- Title
- assign default value in shell script
- Category
- Shell
- Title
- react helmet npm
- Category
- Shell
- Title
- bash set environment variable
- Category
- Shell
- Title
- terminal delete directory not empty
- Category
- Shell
- Title
- hasura squashmigrations
- Category
- Shell
- Title
- how to add images to git readme
- Category
- Shell
- Title
- docker force remove container
- Category
- Shell
- Title
- git push
- Category
- Shell
- Title
- uninstall mysql ubuntu 18.04
- Category
- Shell
- Title
- git unstage file for commit
- Category
- Shell
- Title
- clear untracked files git
- Category
- Shell
- Title
- how to convert ppk to pem in linux
- Category
- Shell
- Title
- if else in mac terminal
- Category
- Shell
- Title
- ubuntu fractional scaling
- Category
- Shell
- Title
- youtube api python
- Category
- Shell
- Title
- pytesseract
- Category
- Shell
- Title
- scp all files in directory
- Category
- Shell
- Title
- pip3 uninstall all
- Category
- Shell
- Title
- deny directory listing htaccess
- Category
- Shell
- Title
- git config core.autocrlf true
- Category
- Shell
- Title
- Warning in install.packages : installation of package ‘tidyverse’ had non-zero exit status
- Category
- Shell
- Title
- bash find file with text
- Category
- Shell
- Title
- git push to branch
- Category
- Shell
- Title
- golang compile with injected variable
- Category
- Shell
- Title
- clone a given branch github
- Category
- Shell
- Title
- inicializar as credenciais no git
- Category
- Shell
- Title
- npm install mongoose error npm ERR! code ENOSELF
- Category
- Shell
- Title
- zip file
- Category
- Shell
- Title
- how to uninstall in ubuntu
- Category
- Shell
- Title
- how to remove commit in git extension
- Category
- Shell
- Title
- mount: cdrom: failed to setup loop device for
- Category
- Shell
- Title
- git flow init
- Category
- Shell
- Title
- how to add extension to all files terminal
- Category
- Shell
- Title
- ubuntu ram type
- Category
- Shell
- Title
- linux delete appledouble ds_store files
- Category
- Shell
- Title
- linux show version
- Category
- Shell
- Title
- run jar file command line
- Category
- Shell
- Title
- pip install crispy_forms
- Category
- Shell
- Title
- foreach powershell
- Category
- Shell
- Title
- deploy to heroku
- Category
- Shell
- Title
- install node in nvm
- Category
- Shell
- Title
- @react-navigation/drawer install
- Category
- Shell
- Title
- how to uninstall node.JS
- Category
- Shell
- Title
- git remove folder remotely
- Category
- Shell
- Title
- how to fix the traceback error debian linux
- Category
- Shell
- Title
- install skimage
- Category
- Shell
- Title
- dotfiles
- Category
- Shell
- Title
- check upstream branch git
- Category
- Shell
- Title
- configurar chave ssh gitlab
- Category
- Shell
- Title
- snap store android studio
- Category
- Shell
- Title
- vue cli upgrade
- Category
- Shell