- Find file in a directory
find <directory> -name "<file name>"
find <directory> -regex "<regex>"
- Search file by keyword/regex
grep -R "<keyword>" <directory>
- Retrieve matching text in a file
grep -oEi '<regex>' <directory>
- Join multiple lines into one line with delimeter
<source of multiple lines> | paste -s -d "<delimiter>"
<source of multiple lines> | perl -pe 's/\n$/ <delimeter text> /'
- Curl with HTTP authentication
curl -u <username>:<password> <url>
- To redirect both
STDOUT
and STDERR
to the same place, use the >&
symbol. To redirect STDOUT
only, use 1>
. To
redirect STDERR
only, use 2>
.
- Separate lines into fields according to delimiter and get selected portion
<source> | cut -d '<delimiter>' -f 1,3-5