惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
Recorded Future
Recorded Future
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
N
News | PayPal Newsroom
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
博客园 - Franky
SecWiki News
SecWiki News
Recent Announcements
Recent Announcements
T
Troy Hunt's Blog
The Register - Security
The Register - Security
The Last Watchdog
The Last Watchdog
Webroot Blog
Webroot Blog
S
Security Affairs
博客园 - 司徒正美
S
Schneier on Security
I
InfoQ
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Forbes - Security
Forbes - Security
腾讯CDC
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic
Cloudbric
Cloudbric
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
B
Blog
V
Vulnerabilities – Threatpost
C
Check Point Blog
Google DeepMind News
Google DeepMind News
Google Online Security Blog
Google Online Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
Schneier on Security
Schneier on Security
O
OpenAI News
K
Kaspersky official blog

mephisto.cc

修复rime-ice无法弹出候选框的问题 开机滚动字体显示优化 个人网站安全防护 树莓派上部署Vaultwarden 使用goaccess实时分析Caddy日志 个人网站监控 Hugo全站AVIF记 Linux下尝试使用Godot开发小游戏 Arch linux dae 透明代理 Airflow接管galler-dl下载任务 如何使用gallery-dl批量下载图像 Arch核显下如何愉快玩Dota2和CS2 Arch/labwc 环境网络相关设置 Rime添加dota2词库 Arch 重装记录 Supertuxkart iOS版终于发布了 打造自己的流媒体音乐服务 剪切板管理工具clipcat推荐 MangoHud性能监控 微信小程序开发记 Rofi试用 解决Arch下VSCode无法输入中文的问题 独立窗口管理器下无法录屏问题处理 上海市二手房成交数据监控 OpenLDAP监控 Arch linux如何顺畅连接蓝牙设备 使用Git和Ansible管理配置文件 Arch Linux SSL VPN 客户端配置 简单获取celery任务实时结果 Arch linux下iNode客户端的安装和使用方法 券商费率调整记 迷你主机组装记 Labwc更换定制皮肤 树莓派跑分流代理 实用自动代理配置示例 九年老鼠标复活记 Openvpn示例 Mac下如何旋转webp图片 如何隐藏Vscode中Markdown PDF插件的头部内容 解决Linux下网络配置无法变更保存的问题 labwc环境启用wlogout Ubuntu下新官方微信尝鲜 简单检测用户是否开启广告屏蔽 Atuin ZFS下卡顿问题解决 Wine安装64位微信 Fish 和 Atuin使用记 Fastapi简单实现临时下载链接 Fastapi微信公众号开发简要 Hugo根据语种展示不同内容 如何修复Waybar微信图标错误 信封加密简要 Linux环境下维护公众号记录 快速隐藏和呼出终端 Wayland环境自动切换壁纸 SuperTuxKart 试玩 简单抓取雪球股票快讯 为什么你的kill命令不能列出信号表 Wine安装微信保姆教程 Hysteria科学上网简要 Ubuntu 23.10 钉钉无法启动解决方法 网站导航栏防止插入Adsense自动广告 Linux环境按键检测 Hugo文末添加最后修改时间 Wayland环境ksnip无法复制问题解决 我眼中的股票市场 Caddy简单图片防盗链 greetd和regreet使用教程 Wayland环境下截图加后期修改 Wayland 环境下gif录屏 Firefox的一些有趣功能 Ubuntu 切换系统语言 Firefox 标题栏高度调整 网站添加回到顶部功能 Hugo自定义字体 Labwc 便捷配置 Wofi使用教程 窗口管理器labwc使用记 文件共享软件Dufs推荐 Hugo静态站点接入Adsense广告 Fcitx5配置详解 Ubuntu安装chrome的方法总结 一种Xterm.js的全屏方案 Google网址收录api Python示例 手机听离线音乐 Snipe it资产导入 应用启动器yofi使用配置 Snipe it资产管理系统安装使用 Ubuntu开机启动加速 Vue3 vite TypeScript跨域等相关设置 Ubuntu手动升级Libreoffice Ubuntu设置alacritty为默认终端 简体文章批量转换为繁体 使用Inkscape调整svg图片大小 使用mitmproxy给手机app抓包 Python中rstrip方法细解 Github同主机多仓库部署deploy key问题处理 Linux安装最新版本Python KeePassXC使用教程 Ubuntu 22.10连接蓝牙耳机报错br-connection-profile-unavailable解决方法 Caddy日志配置轮转和格式化
实用命令
2022-11-17 · via mephisto.cc

本部分内容为日常工作实用命令,会长期更新。

1. 去掉注释行和空行

有时候需要查看某个配置文件的内容,直接查看往往包含很多默认的注释信息,信息混乱翻页麻烦,使用上述命令可去掉行首为#和空行,非#号开始的注释,可自行修改,一般情况够用了。

-E 意思为扩展正则表达式,-v为方向匹配,"^#|^$" 意思匹配#开头或者空行

示例:

1    ➜ grep -Ev "^#|^$" /etc/dnsmasq.conf
2    resolv-file=/etc/resolv.dnsmasq
3    listen-address=127.0.0.1
4    no-hosts
5    hostsdir=/etc/hosts.dnsmasq
6    cache-size=1024

2. 一次性创建多个文件或者目录

1    touch {part1,part2,part3}

mkdir 类似,就是用大括号把东西括起来,在逗号分割待创建的内容,如果是数字或者字母还有变种

请看示例:

 1test touch {one,two,three,four,five}.py
 2test ls
 3    example_dir  five.py  four.py  one.py  three.py  two.py
 4test touch {tony,mike,eric,json,joe}
 5test ls
 6    eric  example_dir  five.py  four.py  joe  json  mike  one.py  three.py  tony  two.py
 7test touch {1..5}.txt
 8test ls -al *.txt
 9    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 14:57 1.txt
10    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 14:57 2.txt
11    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 14:57 3.txt
12    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 14:57 4.txt
13    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 14:57 5.txt
14test touch {a..f}.md
15test ls -al *.md
16    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 15:00 a.md
17    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 15:00 b.md
18    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 15:00 c.md
19    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 15:00 d.md
20    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 15:00 e.md
21    -rw-rw-r-- 1 mephisto mephisto 0 Nov 17 15:00 f.md

3. 查找匹配某种文件后,进一步处理

这些操作当然可以用find + xarg完成,但是fd命令真的很好用,速度非常快。所以我推荐:

1    fd -e zip -x your_next_command

上面的意思为匹配zip结尾,-x 后接你要的命令

示例,先创建10个txt文件,再追加.md结尾,接着把文件复制到example_dir目录

Here, {} is a placeholder for the search result. {.} is the same, without the file extension. {}表示每个匹配的结果,{.}表示每个不带文件后缀名的文件,有点怪,可以看看fd的文档解释。

 1test touch {1..10}.txt
 2test fd . -e txt
 3    1.txt
 4    10.txt
 5    2.txt
 6    3.txt
 7    4.txt
 8    5.txt
 9    6.txt
10    7.txt
11    8.txt
12    9.txt
13test fd . -e txt -x md5sum
14    d41d8cd98f00b204e9800998ecf8427e  ./4.txt
15    d41d8cd98f00b204e9800998ecf8427e  ./2.txt
16    d41d8cd98f00b204e9800998ecf8427e  ./3.txt
17    d41d8cd98f00b204e9800998ecf8427e  ./10.txt
18    d41d8cd98f00b204e9800998ecf8427e  ./6.txt
19    d41d8cd98f00b204e9800998ecf8427e  ./9.txt
20    d41d8cd98f00b204e9800998ecf8427e  ./7.txt
21    d41d8cd98f00b204e9800998ecf8427e  ./8.txt
22    d41d8cd98f00b204e9800998ecf8427e  ./1.txt
23    d41d8cd98f00b204e9800998ecf8427e  ./5.txt
24test fd . -e txt -x mv {} {}.md
25test ls -al
26    total 68
27    drwxrwxr-x  2 mephisto mephisto 12 Nov 17 14:36 .
28    drwxrwxrwt 35 root     root     49 Nov 17 14:33 ..
29    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 10.txt.md
30    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 1.txt.md
31    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 2.txt.md
32    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 3.txt.md
33    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 4.txt.md
34    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 5.txt.md
35    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 6.txt.md
36    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 7.txt.md
37    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 8.txt.md
38    -rw-rw-r--  1 mephisto mephisto  0 Nov 17 14:34 9.txt.md
39test mkdir example_dir
40test fd . -e md -x cp {} example_dir
41test ls -al example_dir
42    total 28
43    drwxrwxr-x 2 mephisto mephisto 12 Nov 17 14:37 .
44    drwxrwxr-x 3 mephisto mephisto 13 Nov 17 14:37 ..
45    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 10.txt.md
46    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 1.txt.md
47    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 2.txt.md
48    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 3.txt.md
49    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 4.txt.md
50    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 5.txt.md
51    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 6.txt.md
52    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 7.txt.md
53    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 8.txt.md
54    -rw-rw-r-- 1 mephisto mephisto  0 Nov 17 14:37 9.txt.md
55test ls
56    10.txt.md  1.txt.md  2.txt.md  3.txt.md  4.txt.md  5.txt.md  6.txt.md  7.txt.md  8.txt.md  9.txt.md  example_dir

4. 排序去重

没有那么多操作很简单 -u 去重,-o 结果输出到另外一个文件

直接看示例:

 1test cat haha.txt
 2    hello
 3    192.168.1.8
 4    192.168.1.9
 5    192.168.1.9
 6    192.168.1.9
 7    192.168.1.9
 8    192.168.1.9
 9    192.168.1.5
10    192.168.1.1
11    192.168.1.3
12    192.168.1.1
13    192.168.1.22
14    world
15test sort -u haha.txt
16    192.168.1.1
17    192.168.1.22
18    192.168.1.3
19    192.168.1.5
20    192.168.1.8
21    192.168.1.9
22    hello
23    world
24test sort -u haha.txt -o result.txt
25test cat result.txt
26    192.168.1.1
27    192.168.1.22
28    192.168.1.3
29    192.168.1.5
30    192.168.1.8
31    192.168.1.9
32    hello
33    world
34test

未完待续...