zoukankan      html  css  js  c++  java
  • Linux文件增删改

    Linux目录/文件增删改

    创建文件

    (1)

    # touch  <文件名称>

     

    (2)

    花括号展开

    touch /root/{1,3,9}.txt

    touch /root/{0..100}.txt  批量创建文件

    删除文件

    rm -f [文件名] 

    -rf  代表强制删除

    批量删除文件

    rm -f *txt

    复制文件

    cp 只能复制文件

    cp -r  可以复制目录

    # cp [option] 源文件  目标文件

    [root@zhang ~]# mkdir /root/{linux,windown}
    [root@zhang ~]# ls
    anaconda-ks.cfg  linux  mysql57-community-release-el7-8.noarch.rpm  windown
    [root@zhang ~]# touch /root/linux/{1,2,3}.txt
    [root@zhang ~]# ls
    anaconda-ks.cfg  linux  mysql57-community-release-el7-8.noarch.rpm  windown
    [root@zhang ~]# cd linux/
    [root@zhang linux]# ls
    1.txt  2.txt  3.txt
    [root@zhang linux]# cd /r
    root/ run/  
    [root@zhang linux]# cd /root/
    [root@zhang ~]# cp /root/linux/1.txt /root/windown/
    [root@zhang ~]# cd windown/
    [root@zhang windown]# ls
    1.txt
    [root@zhang windown]# cd ..
    [root@zhang ~]# ls
    anaconda-ks.cfg  linux  mysql57-community-release-el7-8.noarch.rpm  windown
    [root@zhang ~]# cp /root/linux/2.txt /root/windown/2.jpg
    [root@zhang ~]# cd windown/
    [root@zhang windown]# ls
    1.txt  2.jpg
    

     -r   复制文件目录

    [root@zhang ~]# cp -r /root/linux/ windown/
    [root@zhang ~]# ls
    anaconda-ks.cfg  linux  mysql57-community-release-el7-8.noarch.rpm  windown
    [root@zhang ~]# cd windown/
    [root@zhang windown]# ls
    1.txt  2.jpg  linux
    [root@zhang windown]# cd linux/
    [root@zhang linux]# ls
    1.txt  2.txt  3.txt
    

    -fn 强制覆盖

    [root@zhang ~]# cp -fn /root/linux/1.txt /root/windown/

    移动文件

    #mv 源文件 目标文件

     

    文件重名

     

     

  • 相关阅读:
    阿里云 CDN+OSS 解决方案
    一次完整的HTTP请求过程
    apache多站点配置中ServerAlias什么意思
    legend3---apache配置https
    legend3---Fiddler如何抓手机app的包
    Fiddler:增加IP列
    http请求报文格式和响应报文格式
    http请求头中Referer的含义和作用
    Chrome保存的HAR文件怎么打开
    Android Studio 错误 Duplicate files copied in APK META-INF/LICENSE.txt
  • 原文地址:https://www.cnblogs.com/heian99/p/11972344.html
Copyright © 2011-2022 走看看