-
cd ..
Change to the parent directory -
cd -
Change to the previous directory -
open .
Open current folder in Finder -
which <command>
Show command path -
mkdir <dir1> <dir2> <dirn>
Create directory or directories -
rm -r <dir>
Delete all files and then the folder itself -
touch <file>
Create a file -
rm <file>
Delete the file -
cp <original_file> <new_file>
Make a copy file -
find . -name <file>
Find the file in current folder -
find . -name *<ending>
Find all files with the specified extension -
find . -empty
Find all empty files -
ln -s <original_path> <symbolic_link>
Creates symbolic link -
find . -type f | wc -l
File count under a directory -
wc -l filename
Count line number -
wc -w < filename
Count word number in a file -
grep -o "word" filename | wc -l
Count specific word in a file -
head -k filename
Print first k lines -
find . -name \*.extension -exec grep -q "specifiedkeyword" '{}' \; -print
Find all specified keyword in all files with an extension -
Find all words starting with xy
grep -E '\bxy' filename -
grep -E 'xy\b' filename
Find all words ending with xy -
head -n +k sourcefile > targetfile
Take and extract first k lines from a file into a target file -
cat * > targetfile
Merge all files into one file under a directory -
head -n +k sourceFileName > targetFileName
Take first k lines from a file
-
echo -n -e "\033]0;YOUR TITLE HERE\007"
Change Terminal title -
zsh --version
Check zsh version -
upgrade_oh_my_zsh
Upgrade zsh -
source ~/.zhrc
Apply changes
-
brew update
-
Upgrade a package
brew upgrade <package>
-
brew install <package>
-
brew uninstall <package>
-
brew info <package>
Get the information before installing the package -
brew doctor
-
brew cleanup
Remove broken symlinks -
brew link
IMPORTANT: Do not delete python2 folders or files under /System/Library
and /usr/bin
-
Check all Python installations
which python python2 python2.7 python3 python3.6 python3.8
-
Remove the third-party Python 2.7 framework
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
-
Remove the Python 2.7 applications directory
sudo rm -rf "/Applications/Python 2.7"
-
Show symbolic links
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7'
-
Remove all symlinks
cd /usr/local/bin/ && ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm
-
If necessary, edit your shell profile file(s) to remove adding
/Library/Frameworks/Python.framework/Versions/2.7
to yourPATH
environment file:~/.bash_login
or~/.bash_profile
or~/.zprofile
-
If you want to work with python3 instead of Python 2's python, simply add this alias to your
~/.zprofile
alias python='python3'
-
python3 --version
pip3 --version
Check versions -
brew install python3
brew upgrade python3
Install and update Python -
python3 -m pip install --upgrade pip setuptools wheel
Update pip, setuptools, and wheel -
pip3 install --upgrade <package>
Upgrade packages
https://docs.python-guide.org/dev/virtualenvs/#virtualenvironments-ref