歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> SHELL編程 >> Linux shell中反引號(`)的應用

Linux shell中反引號(`)的應用

日期:2017/2/28 14:26:27   编辑:SHELL編程

反引號位 (`) 位於鍵盤的Tab鍵的上方、1鍵的左方。注意與單引號(')位於Enter鍵的左方的區別。

反引號位 (`)在Linux中起著命令替換的作用。命令替換是指shell能夠將一個命令的標准輸出插在一個命令行中任何位置。

舉個例子:

[email protected]:~$ date
2014年 10月 29日 星期三 15:14:46 CST
[email protected]:~$ echo `date` | cut -d' ' -f1-4
2014年 10月 29日 星期三

可以看出,反引號``內的date命令先被執行,然後將date命令輸出替換到相應位置。

很有效的元字符,在shell中會常用到。

Shell編程淺析 http://www.linuxidc.com/Linux/2014-08/105379.htm

Linux Shell參數替換 http://www.linuxidc.com/Linux/2013-06/85356.htm

Shell for參數 http://www.linuxidc.com/Linux/2013-07/87335.htm

Linux/Unix Shell 參數傳遞到SQL腳本 http://www.linuxidc.com/Linux/2013-03/80568.htm

Shell腳本中參數傳遞方法介紹 http://www.linuxidc.com/Linux/2012-08/69155.htm

Shell腳本傳遞命令行參數 http://www.linuxidc.com/Linux/2012-01/52192.htm

Linux Shell 通配符、轉義字符、元字符、特殊字符 http://www.linuxidc.com/Linux/2014-10/108111.htm

Copyright © Linux教程網 All Rights Reserved