2. AGENDA
Find anything with “grep”
Quick command with “alias”
Commands combination with “|”
Suggest commands with “apropos”
Some other useful commands
1.
2.
3.
4.
5.
3. WHY NOT USE FINDER
time waste in searching what’s inside file
not search the hidden file
not flexible: result all contain either “TMX” or “Map” when
search exactly “TMX Map”
limited by searching by keywords only
•
•
•
•
4. FIND ANYTHING WITH
GREPgrep options pattern file...
some useful options
•
•
Text in Subfolder -r grep -r “TMX Map” .
Find any file in sub folder of current folder
Whole words only -w grep -w “Map”
Find Map only, not mapping, maps, mapped
Case-insensitive text -i grep -i “map”
Return all Map, MAP, map, ....
File name only -l grep -l “TMX Map”
Find all file contain TMX Map, but return filename only
Number of occurrences
only
-c grep -c “TMX Map”
Return all file and number of hits TMX Map in each file
Search using regular expression•
5. QUICK COMMAND WITH
ALIAS
sometimes type something like this is like ****
mysql -uroot -p
rvm_reload_flag=1 source '''/Users/kien_metalrock/.rvm/scripts/rvm''
wine ~/.wine/drive_c/Program Files/Oxford/Oxford Collocations
Dictionary/ocoll2e.exe
......
and many so long with complex options commands
•
6. QUICK COMMAND WITH
ALIAS
Make command become shorter and readable
alias mysql= 'mysql -uroot -p '
alias rvm_restart= 'rvm_reload_flag=1 source
'''/Users/kien_metalrock/.rvm/scripts/rvm'''
alias oxford= 'wine ~/.wine/drive_c/Program
Files/Oxford/Oxford Collocations Dictionary/ocoll2e.exe'
•
•
•
•
7. COMMAND COMBINATION
WITH PIPE (|)
The output of command before will be input of after
command
Examples:
grep -r "TMX Map" . | grep "Objects"
history | grep "git"
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
•
•
•
•
•
8. SUGGEST COMMAND WITH
APROPOS
sometimes you want to do something but don’t remember
exactly what command should be used?
apropos keyword
Examples:
apropos git
apropos pattern
apropos disk space
•
•
•
•
•
•
9. SOME OTHER USEFUL
COMMANDS
ln make links
cd - back to before folder
w show who are logged on and what they are doing
last the last users logged in
history show all command in history
which,
whereis
where does the command come from
df -h, du -h disk usage statistics
split & cat split & concat file