亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1201 | 回復(fù): 1
打印 上一主題 下一主題

[系統(tǒng)管理] bash腳本里加雙引號(hào)與不加的區(qū)別 [復(fù)制鏈接]

論壇徽章:
1
操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-01-20 06:20:00
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2016-05-12 19:19 |只看該作者 |倒序?yàn)g覽
本帖最后由 bobower 于 2016-05-12 19:20 編輯

話不多說,直接上示例說明:
/tmp/test]# ls
1  2  3  4  test.sh
/tmp/test]# cat test.sh
#!/bin/bash
echo `ls .`
### 重點(diǎn)1
/tmp/test]# sh test.sh
1 2 3 4 test.sh


/tmp/test]# vi test.sh
/tmp/test]# cat test.sh
#!/bin/bash
echo "`ls .`"
###重點(diǎn)2
/tmp/test]# sh test.sh
1
2
3
4
test.sh

說明:目錄/tmp/test下有5個(gè)文件,其中test.sh是執(zhí)行腳本,其余是隨手創(chuàng)建的測(cè)試文件。
第1次執(zhí)行test.sh,沒有雙引號(hào),輸出了一行。
然后修改了test.sh,加上了雙引號(hào),輸出的每個(gè)文件都占一行。
疑問:只是加了一個(gè)雙引號(hào),導(dǎo)致輸出格式發(fā)生變,不太明白其中原因,請(qǐng)大神幫忙解答,多謝了~!




論壇徽章:
2
操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-05-16 06:20:0015-16賽季CBA聯(lián)賽之八一
日期:2016-05-18 15:38:22
2 [報(bào)告]
發(fā)表于 2016-05-13 16:54 |只看該作者
  1. Command Substitution
  2.        Command substitution allows the output of a command to replace the command name.  There are two forms:

  3.               $(command)
  4.        or
  5.               `command`

  6.        Bash  performs  the expansion by executing command and replacing the command substitution with the standard output of the
  7.        command, with any trailing newlines deleted.  Embedded newlines are not deleted, but they  may  be  removed  during  word
  8.        splitting.  The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).
復(fù)制代碼
執(zhí)行``的時(shí)候,會(huì)把里面的換行用空格替換掉。
  1. yu@yu-vm:~/0513$ awk '{print $1}' 1.txt
  2. a
  3. b
  4. c
  5. d
  6. a
  7. b
  8. a
  9. c
  10. yu@yu-vm:~/0513$ echo `awk '{print $1}' 1.txt`
  11. a b c d a b a c
  12. yu@yu-vm:~/0513$ echo "`awk '{print $1}' 1.txt`"
  13. a
  14. b
  15. c
  16. d
  17. a
  18. b
  19. a
  20. c
  21. yu@yu-vm:~/0513$
復(fù)制代碼
至于ls為啥單獨(dú)執(zhí)行的時(shí)候不會(huì)換行,這個(gè)man ls也沒查到。期待大神來解答下
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP