★ Linux下简单排除字符串的几种方法(awk、sed、grep)
  • 思路1:通过awk取反来排除掉文本bb
[root@ tmp]# awk '!/bb/' a.txt
aa
cc
  • 思路2:通过sed命令,排除掉第二行文本
[root@ tmp]# sed '/bb/d' a.txt
aa
cc
  • 思路3:通过grep -v参数排除文本bb
[root@ tmp]# grep -v "bb" a.txt
aa
cc
★ requirements.txt 自动生成和安装
  • 生成requirements.txt文件
pip3 freeze > requirements.txt
  • 安装requirements.txt依赖
pip3 install -r requirements.txt
★ Ubuntu 20.04 添加当前用户 Root 权限,sudo操作免密
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
kcui    ALL=(ALL:ALL) ALL    #用户kcui添加ROOT权限

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
kcui    ALL=(ALL:ALL) NOPASSWD:ALL  #用户kcui添加sudo免密
# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
★ OpenWrt 自动更改 WAN MAC地址:
oldmac=$(ifconfig eth0.2 |grep HWaddr |head -n 1 | grep -o  "[a-f0-9A-F]\\([a-f0-9A-F]\\:[a-f0-9A-F]\\)\\{5\\}[a-f0-9A-F]")
newmac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
echo $oldmac
echo $newmac
sed -i "s/$oldmac/$newmac/gi" /etc/config/network
★ find 文件并复制:
find . -type f -name "*.img" | xargs cp -t ./upload_tmp
最后修改:2022 年 04 月 05 日
如果觉得我的文章对你有用,请随意赞赏
END
本文作者:
文章标题:Shell 常用命令笔记
本文地址:https://blog.abcdl.cn/index.php/archives/13/
版权说明:若无注明,本文皆iStar Blog原创,转载请保留文章出处。