Let's check out another interesting Unix-related Techbit related to avoiding the usage of commands when they're not necessary.
Such usages are also fondly referred in "Useless use of ..." category awards :-) There're many varieties under this class like "Useless use of cat", "Useless use of grep & awk", "Useless use of wc -l" etc. Provided below are few.
Such usages are also fondly referred in "Useless use of ..." category awards :-) There're many varieties under this class like "Useless use of cat", "Useless use of grep & awk", "Useless use of wc -l" etc. Provided below are few.
Useless use of "cat"
cat file.txt | grep pattern
can very well be expressed as grep pattern file.txt
Useless use of "grep"
ps -ef | grep java | grep -v grep
can be ps -ef | grep '[j]ava'
ps -ef | grep java | awk '{print $2}'
can just become ps -ef | awk '/java/ {print $2}'
Useless use of "wc"
ls -1 | grep pattern | wc -l
can be written as ls -1 | grep -c pattern
No comments:
Post a Comment