Linux 常用命令-touch, cp, mv, rm

  • touch:
    • 创建空文件: touch filename
      • 示例: touch test.txt
    • 改变文件的修改时间: touch existedFileName
      • 示例: touch test.txt
    • 改变文件的访问时间: touch -a existedFileName
      • 示例: touch -a test.txt
      • 访问时间查看: li -l --time=atime test.txt
  • cp:
    • 复制文件: cp sourceFileName targetFileName
      • 示例: cp test.txt test.txt.copy
    • 复制文件提示是否覆盖已存在目标文件: cp -i sourceFileName targetFileName
      • 示例: cp -i test.txt test.txt.copy
        若目标文件已存在则会提示是否覆盖已有文件, 若是才继续.
    • 递归复制: cp -r sourceFileName targetFileName
      • cp -r src/* destination/
  • mv:
    • 重命名文件: mv oldFileName newFileName
      • 示例: mv test.txt test1.txt
    • 移动文件: mv sourceFile targetFolder
      • 示例: mv test.txt ./study/
        和 cp 命令一样可以使用 -i 来提示是否覆盖已有文件
  • rm:
    • 删除文件: rm -i fileName
      • 示例: rm -i test.txt
    • 递归删除: rm -rf folder
      • 示例: rm -rf ./study
        递归删除时为了避免提示符, 可以使用 -f 参数强制删除.
  • 参考:
    [1] : linux命令行与shell脚本编程大全
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章