Linux Bash Scripting - Command Substitution

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux Bash Scripting - Command Substitution相关的知识,希望对你有一定的参考价值。

` - back close or reverse close

shift +tilder


?Command Expansion


cat > lspath.txt

/etc

^C


ls -l  `cat lspath.txt` | grep .conf > etcconf.file

OR

ls -l $(cat lspath.txt)


another example using "du" command:

du -h `cat lspath.txt`


set | grep ETCDIR

ETCDIR=`ls -l /etc`

echo $ETCDIR  ## to reserve the normal format, use echo "$ETCDIR"


netstat -ant | grep 443


### checking https status, if result is 1, it is running; if result is 0, https service is dead###

ssl_status=`netstat -ant | grep 443 | wc -l`

echo $ssl_status








以上是关于Linux Bash Scripting - Command Substitution的主要内容,如果未能解决你的问题,请参考以下文章

Bash Scripting Learn Notes

[Bash Scripting LOOP]for, while. until

[Bash Scripting LOOP]for, while. until

编程实践Bash Scripting with ChatGPT: Highlight Syntax使用 ChatGPT 编写 Bash 脚本:突出显示语法

《Advanced Bash-scripting Guide》学习(十九):两个整数的最大公约数

《Advanced Bash-scripting Guide》学习(十七):用more来查看gzip文件