Unix Tricks
2013-12-24
Here are a few Unix command line tricks that I've learned recently.
... | vim -
Edit search results by piping text into vim -
instead of less
.
grep '127.0.0.1' file.log | less
grep '127.0.0.1' file.log | vim -
tr -s ' '
Squeeze consecutive spaces into a single space. Also works for other characters.
ps aux | tr -s ' ' | cut -f1,2,3 -d' '
grep -B/-A
Display lines before (-B
) and after (-A
) a matching line.
I find these flags confusing, since they could be "Above" and "Below".
grep -A3 '<Directory' /etc/apache2/apache2.conf