linux命令学习-首篇

来源:互联网 发布:sql2005数据修复 编辑:程序博客网 时间:2024/06/05 08:01

在home目录的.bashrc 添加了如下逻辑,目的是可以"每日"学习或复习linux命令


# 学习linux命令# echo "Did you know that:"; whatis $(ls /bin | shuf -n 1)cowsay -f $(ls /usr/share/cowsay/cows | shuf -n 1 | cut -d. -f1) $(whatis $(ls /bin) 2>/dev/null | shuf -n 1)


效果图:



参考文章: http://www.geekfan.net/6603/


上面逻辑的解读:


前置基础知识点:

$(xxx) : 即运行bash脚本且得到脚本的输出信息(字符串)

2>/dev/null : 错误输出重定向到黑洞(垃圾箱),支除噪音 注: /dev/null是linux的空设备

cowsay: 是生成ASCII图像的程序,显示一头牛在说话;

whatis : 输出某个linux命令的功能简介; 

shuf: 将内容随机输出;


具体逻辑分析:

echo "Did you know that:"; whatis $(ls /bin | shuf -n 1)
1.ls /bin 列出/bin目录下的linux命令;
2.shuf -n 1 随机选择一条linux命令;
3.输出命令的功能简介


cowsay -f $(ls /usr/share/cowsay/cows | shuf -n 1 | cut -d. -f1) $(whatis $(ls /bin) 2>/dev/null | shuf -n 1)

1.如上 $(whatis $(ls /bin) 2>/dev/null | shuf -n 1) 获取命令功能简介;

2.随机选一个图片主角,说话的小动物 ls /usr/share/cowsay/cows | shuf -n 1 | cut -d. -f1 

3.输出内容(ASCII 图)

0 0
原创粉丝点击