zoukankan      html  css  js  c++  java
  • 禁止使用rm命令与删除filename之外的文件

    1、使用rm命令时提示Do not use rm command

    alias rm='echo Do not use rm command'

    使rm提示生效 /etc/profile。 . /etc/profile或者 source /etc/profile

    vim /etc/profile(先执行)

    vim /etc/bashrc (后执行)

    后执行的掩盖先执行的命令。所以只要修改~/.bashrc

    2删除filename之外的文件

    [root@localhost QQ]# touch 1.txt 2.txt 3.txt 4.txt
    [root@localhost QQ]# ls
    1.txt 2.txt 3.txt 4.txt

    删除4.txt之外的文件。

    第一种方法:

    [root@localhost QQ]# ls |grep -v "4.txt"|xargs rm -f
    [root@localhost QQ]# ls
    4.txt

    第二种方法:

    [root@localhost QQ]# find ./ -type f ! -name "3.txt"|xargs rm -f
    [root@localhost QQ]# ls
    3.txt

  • 相关阅读:
    02_类和对象
    Django_数据库增删改查——增
    Django_同步数据库
    Django_models类属性。
    CSS_垂直居中
    CSS_背景属性
    CSS_定位
    CSS_浮动
    CSS_盒子模型
    CSS_元素的分类
  • 原文地址:https://www.cnblogs.com/xusx/p/6040321.html
Copyright © 2011-2022 走看看