grep cheat sheet
Shell
#!/bin/sh
#http://www.thegeekstuff.com/2011/01/advanced-regular-expressions-in-grep-command-with-10-examples-%E2%80%93-part-ii/
# GENERAL
# print lines begining with range of letters
grep ^[A-D] table.txt
# REGEX
# search for word which has any single character followed by ello
grep ".ello" demo.txt
# OR, all the below examples produce the same results
grep "stuff\|more" demo.txt
grep -E "stuff|more" demo.txt
grep -e "stuff" -e "more" demo.txt
# AND, there is no AND so regex works
grep 'Manager.*Sales' employee.txt
# AND & OR
grep 'Manager.*Sales\|Developer*Tech' employee.txt
# begin with 1 and endswith C
grep '^1.*C$' file.txt
# FLAGS
# print everything that doesn't contain the query
grep -v ^Da* table.txt
# -i forgets about case sensitivity
grep -i ^DA table.txt
# show only the matched string, not the entire line in which it is present within.
grep -o "Meow" table.txt
# print the file containing the query including thos within subdirs
grep -r ^David ~/scripts-x14.04/bash/*
# print the name of the file(s) which matches the query
grep -l ^David ~/some_dir/*
# count the number of matches
grep -c "stuff" table.txt
# show the line numbers of the matches
grep -n "go" demo.txt
# search only for the full word
grep -w "of" table.txt
# print 3 lines after the match (-B for before the match & -C for before and after)
grep -A 3 "of" table.txt
Also in Shell:
- Title
- linux check ubuntu version
- Category
- Shell
- Title
- pycharm duplicate line
- Category
- Shell
- Title
- powershell script enable tls 1.2
- Category
- Shell
- Title
- how to download a git repository
- Category
- Shell
- Title
- what does pro mean in github
- Category
- Shell
- Title
- linux command to check memory usage in percentage
- Category
- Shell
- Title
- htaccess secure
- Category
- Shell
- Title
- cmd prompt format
- Category
- Shell
- Title
- package 'mana-toolkit' has no installation candidate
- Category
- Shell
- Title
- .gitignore not working
- Category
- Shell
- Title
- git list remote branches
- Category
- Shell
- Title
- Macbook git user config global
- Category
- Shell
- Title
- git reset hard
- Category
- Shell
- Title
- how to update local repo when i make changes to github remote repo
- Category
- Shell
- Title
- install express globally
- Category
- Shell
- Title
- git global username --replace-all
- Category
- Shell
- Title
- react quill
- Category
- Shell
- Title
- check ram memory usage linux
- Category
- Shell
- Title
- conda install paraview
- Category
- Shell
- Title
- linux install ifconfig
- Category
- Shell
- Title
- Data path ".builders['app-shell']" should have required property 'class'.
- Category
- Shell
- Title
- git rebase one commit
- Category
- Shell
- Title
- Why are there two ways to unstage a file in Git?
- Category
- Shell
- Title
- linux os upgrade
- Category
- Shell
- Title
- netstat column headers
- Category
- Shell
- Title
- cancel commit before push
- Category
- Shell
- Title
- shell count number of lines
- Category
- Shell
- Title
- reset branch on local git
- Category
- Shell
- Title
- mongodb shell query last document
- Category
- Shell
- Title
- screen recorder linux
- Category
- Shell
- Title
- git clean remote branches
- Category
- Shell
- Title
- improve ubuntu 16.04 performance
- Category
- Shell
- Title
- ubuntu chmod codes
- Category
- Shell
- Title
- powershell search array
- Category
- Shell
- Title
- delete local branch git
- Category
- Shell
- Title
- How do I show the changes which have been staged
- Category
- Shell
- Title
- change ratio vmware ubuntu
- Category
- Shell
- Title
- intel pinning threads
- Category
- Shell
- Title
- ubuntu 16.04 bluetooth not detecting devices
- Category
- Shell
- Title
- git get access to private repository
- Category
- Shell
- Title
- check ubuntu version cmd
- Category
- Shell
- Title
- How do I see which version of Swift I'm using
- Category
- Shell
- Title
- git show staged files
- Category
- Shell
- Title
- local-gen install
- Category
- Shell
- Title
- powershell get ip address
- Category
- Shell
- Title
- gunicorn launch django cmd
- Category
- Shell
- Title
- register runner gitlab
- Category
- Shell
- Title
- remove all iptables rules
- Category
- Shell
- Title
- set remote url git
- Category
- Shell
- Title
- git reset
- Category
- Shell
- Title
- numpy uninstall anaconda
- Category
- Shell
- Title
- npm list global packages
- Category
- Shell
- Title
- ng2-dragula valor software github
- Category
- Shell
- Title
- install sailsjs
- Category
- Shell
- Title
- install AdminLTE
- Category
- Shell
- Title
- /usr/local/share/doc/node is not writable.
- Category
- Shell
- Title
- bash get first argument
- Category
- Shell
- Title
- brew minikube custom version install
- Category
- Shell
- Title
- ngb-tabset install
- Category
- Shell
- Title
- join linux to ad domain
- Category
- Shell
- Title
- bash find file with text
- Category
- Shell
- Title
- git tag checkout
- Category
- Shell
- Title
- how to set date in linux
- Category
- Shell
- Title
- qpdf decrypt with password
- Category
- Shell
- Title
- bash generate random number between
- Category
- Shell
- Title
- linux get current user
- Category
- Shell
- Title
- how to get ssh access to a computer
- Category
- Shell
- Title
- powershell download a file from url
- Category
- Shell
- Title
- grep cheat sheet
- Category
- Shell
- Title
- yarn ubuntu
- Category
- Shell
- Title
- git change remote origin address
- Category
- Shell
- Title
- bash get field from line
- Category
- Shell
- Title
- ubuntu crop pdf
- Category
- Shell
- Title
- docker run command on container
- Category
- Shell
- Title
- chown
- Category
- Shell
- Title
- heic open linux
- Category
- Shell
- Title
- git add all files command
- Category
- Shell
- Title
- ubuntu installing gimp
- Category
- Shell
- Title
- find and replace in all files in directory centos
- Category
- Shell
- Title
- how to check upstream git
- Category
- Shell
- Title
- install openjdk 8 sdk on ubuntu
- Category
- Shell
- Title
- setup android studio in ubuntu
- Category
- Shell
- Title
- install babel language
- Category
- Shell
- Title
- docker node alpine
- Category
- Shell
- Title
- adding an existing project to github using the command line
- Category
- Shell
- Title
- ubuntu delete from ssh known hosts
- Category
- Shell
- Title
- edit files from terminal linux
- Category
- Shell
- Title
- how to install mongoose
- Category
- Shell
- Title
- node install ubuntu
- Category
- Shell
- Title
- Error: ENOSPC: System limit for number of file watchers reached
- Category
- Shell
- Title
- linux find file containing text
- Category
- Shell
- Title
- how to use sass in react without eject
- Category
- Shell
- Title
- install wireguard
- Category
- Shell
- Title
- how to install jest
- Category
- Shell
- Title
- install bootstrap in laravel
- Category
- Shell
- Title
- files not showing in ubuntu
- Category
- Shell
- Title
- shell promt user input
- Category
- Shell
- Title
- manjaro network driver installed but not working
- Category
- Shell
- Title
- pip install tensorflow not working
- Category
- Shell
- Title
- start mariadb on linux terminal
- Category
- Shell