linux查看当前shell的方法
這篇文章主要對比一下 source 命令執(zhí)行shell文件和 ./ping.sh 這種方式執(zhí)行shell文件的區(qū)別。
1. source ? ping.sh 這個是在當前的shell 中執(zhí)行 ping.sh 里面的內(nèi)容的。(source 和 . 是相同的,It has a synonym in?.?(period))
怎么查看當前的shell呢?
$$ 這個會輸出當前shell的pid, echo $SHELL 這個變量直接輸出當前shell ,我們這里是“/bin/bash”
?
#!/bin/bash # 1、ping -c1 -w1 中-c1是指ping的次數(shù),-w是指執(zhí)行的最后期限,也就是執(zhí)行的時間,單位為秒 # 2、&>/dev/null 是指標準輸出和錯誤輸出都輸出到/dev/null上,而不在界面上顯示; # 后面的&&和|| 是與和或得意思,如a&&b||c ,表示a為真,則執(zhí)行b;否則執(zhí)行cfor I in `seq 1 254`; doping -c1 -w1 192.168.123.$I &>/dev/null && echo "192.168.123.$I is up" || echo "$I down" done
這個ping.sh在當前的shell中執(zhí)行的,相當于 ping 命令是一條一條輸入到當前的shell 中的。
參考:?
source?is a bash shell built-in command that executes the content of the file passed as argument,?in the current shell. It has a synonym in?.?(period).
Syntax
. filename [arguments] source filename [arguments]?------------------------------------------------------------------------------------------------------------------------------
2. ?./ping.sh 執(zhí)行
?
?
轉載于:https://www.cnblogs.com/oxspirt/p/9804269.html
總結
以上是生活随笔為你收集整理的linux查看当前shell的方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: win10系统怎么看无线密码是多少 查看
- 下一篇: Linux环境下如何编译和执行c程序