【Linux】理解和解释shell命令的工具

  • 🐚作者简介:花神庙码农(专注于Linux、WLAN、TCP/IP、Python等技术方向)
  • 🐳博客主页:花神庙码农 ,地址:https://blog.csdn.net/qxhgd
  • 🌐系列专栏:C语言编程
  • 📰如觉得博主文章写的不错或对你有所帮助的话,还望大家三连支持一下呀!!! 👉关注✨、点赞👍、收藏📂、评论。
  • 如需转载请参考转载须知!!

explainshell网站

  • 在搜索框中输入你要查询的命令,explainshell 会分析命令的帮助文档根据你想查询的命令参数来给出对应的解释,这样就能快速了解神秘 shell 指令的作用是什么啦。

在这里插入图片描述

explain shell脚本

简介

  • Jackson写了一小段代码,它能非常有效地在bash shell里面解释shell命令,可能最美之处就是你不需要安装第三方包了。他把包含这段代码的的文件命名为“explain.sh”。

安装explain shell脚本

  • 首先,安装curl:
# apt-get install curl [On Debian systems]
# yum install curl [On CentOS systems]
  • 其次,在.bashrc中增加explain函数:
# explain.sh begins
explain () {
if [ "$#" -eq 0 ]; then
while read -p "Command: " cmd; do
curl -G --ciphers ecdhe_ecdsa_aes_128_sha "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd"
done
echo "Bye!"
elif [ "$#" -eq 1 ]; then
curl -G --ciphers ecdhe_ecdsa_aes_128_sha "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1"
else
echo "Usage"
echo "explain interactive mode."
echo "explain 'cmd -o | ...' one quoted command to explain it."
fi
}
  • 最后,执行.bashrc,之后就可以随意的使用了。
$ source .bashrc

用法

直接解释简单的命令
$ explain 'du -h'
$ explain 'tar -zxvf'
交互模式
  • 在终端输入explain命令进入交互模式:
$ explain
  • 然后一个接着一个地输入命令,就能在一个窗口看到他们各自的作用:
Command: whatis
Command: whereis
  • 通过Ctrl + C,可退出交互模式。
也可解释由管道连接的复合命令:
$ explain 'ls -l | grep -i qxhgd'

小结

  • 除了本文介绍的两个工具,也可以借助实现流行的AI工具。

如本文对你有些许帮助,欢迎大佬支持我一下(点赞+收藏+关注、关注公众号等),您的支持是我持续创作的不竭动力
支持我的方式

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

花神庙码农

你的鼓励是我码字的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值