Re: [問題]awk與csh 搭配傳入外部變數的問題

看板Linux作者 (Rickie Yang)時間9年前 (2015/03/28 03:07), 編輯推噓0(003)
留言3則, 3人參與, 最新討論串2/2 (看更多)
太多行不好推文, 原諒我用回文浪費一下版面. 我用 Mac (10.10.2) 試, 結果是你要的耶. 這中間肯定有什麼誤會... Area51-MBP:0 rickie$ cat 1.txt 3-6 aaaa.tif 4 bbbb.tif 9-7 cccc.tif Area51-MBP:0 rickie$ cat 2.txt 1 2 3-6 4 5-0 9-7 Area51-MBP:0 rickie$ cat test.sh #!/bin/csh foreach a(`cat 2.txt`) awk '{if ($1==a) print $0}' a=$a 1.txt end Area51-MBP:0 rickie$ ./test.sh 3-6 aaaa.tif 4 bbbb.tif 9-7 cccc.tif Area51-MBP:0 rickie$ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.222.17.107 ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1427483244.A.6EE.html

03/28 17:01, , 1F
因為Mac是BSD系的?
03/28 17:01, 1F

03/28 21:54, , 2F
原 po 說他用 Mac, 我才特地開 Mac 試的呀.
03/28 21:54, 2F

03/28 22:00, , 3F
mac 也有 bash/csh/tcsh 等等,行為應該結果一樣
03/28 22:00, 3F
文章代碼(AID): #1L5QfiRk (Linux)
文章代碼(AID): #1L5QfiRk (Linux)