Linux 命令实践

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环境变量值
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值