mkdir
- mkdir doc 新建doc文件夹
touch
- touch hello.txt 新建文件
mv
- mv 移动或重命名
cp
- cp A B
rm
- rm hello.txt 删除文件
- rm -r doc 删除文件夹
cat
- cat file.txt 显示文件内容
- cat hello1.txt > hello2.txt 用hello1.txt替换hello2.txt 的内容
- cat hello1.txt >> hello2.txt hello1.txt的内容追加到hello2.txt的后面
sort
- sort hello.txt 排序后显示内容
- cat lakes.txt | sort > sorted-lakes.txt 将排序后的内容输出到sorted-lakes.txt
uniq
- uniq hello.txt 显示并删除重复行(只删除挨着的重复行)不会修改文件本身
- sort deserts.txt | uniq 显示排序后的无重复行
- sort deserts.txt | uniq > uniq-deserts.txt 排序后删除重复行,并存入文件
grep
- grep Mount mountains.txt 显示包含Mount的行
- grep -i Mount mountains.txt 显示不包含Mount的行
- grep -R Arctic /home/ccuser/workspace/geography 查找geography文件夹下 所有包含 Arctic内容的文件名,并显示该行
- grep -R Arctic /home/ccuser/workspace/geography 只显示过滤后的文件名
nano
- nano ~/.bash_profile 打开文件 Ctrl+字母O 保存 Ctrl+X 退出
env
- env 显示所有的环境变量
- env | grep PATH 过滤PATH
- .bash_profile文件内容 :
- alias ll=”ls -la” 别名
- alias hy=”history”
- export USER=”Jane Doe” 环境变量USER
- export PS1=”>> ” 命令行提示符环境变量修改为>>
- source ~/.bash_profile 使.bash_profile生效
- echo $USER 显示USER环境变量值