- To use a Color GREP to only highlight matched patterns but not otherwise change the output:
grep --color=always -e "^" -e "hello" testfile
- Find a pattern in all files
grep -rnw '/path/to/somewhere/' -e 'pattern'
* -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.
- To find only with certain extension
grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
- To exclude certain extension
grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
- To exclude dirs
grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
- Bind a port connecting to a remote server. (Eg: tensorboard running on remote server)
ssh -N -f -L localhost:16006:localhost:6006 <user@remote>
-N : no remote commands
-f : put ssh in the background
-L <machine1>:<portA>:<machine2>:<portB> :