Shell是硬件和软件之间的交互界面。Bash是一种shell,在Linux系统中比较常见。我目前使用的Mac用的Z shell(zsh). 可以在terminal里面通过zsh命令对系统进行操作。这是与Windows所见所得,用鼠标点相比,Mac和Linux都可以完全用命令操作。常用的Bash/zsh命令如下:
Bash语言学习主要靠多用,慢慢积累。遇到需求多找资料,常学常用吧。
File and Directory Operations
bash
ls # List files
ls -l # Long listing with details
cd /path/to/dir # Change directory
pwd # Show current directory
mkdir newdir # Create directory
touch file.txt # Create empty file
rm file.txt # Delete file
rm -r dir/ # Delete directory and contents
cp file1 file2 # Copy file
mv old new # Move or rename file
Viewing and Editing Files
bash
cat file.txt # Show file contents
less file.txt # View file page-by-page
head file.txt # First 10 lines
tail file.txt # Last 10 lines
nano file.txt # Open in Nano editor
vim file.txt # Open in Vim editor