awk與csh 搭配傳入外部變數的問題 - Linux
By Lily
at 2015-03-28T03:07
at 2015-03-28T03:07
Table of Contents
太多行不好推文, 原諒我用回文浪費一下版面.
我用 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$
--
我用 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$
--
Tags:
Linux
All Comments
By Hedda
at 2015-03-31T08:00
at 2015-03-31T08:00
By Callum
at 2015-04-02T11:32
at 2015-04-02T11:32
By Suhail Hany
at 2015-04-03T15:18
at 2015-04-03T15:18
Related Posts
suse 11 裝不起來
By Cara
at 2015-03-27T16:10
at 2015-03-27T16:10
ls [^A-Z]* ?
By Yedda
at 2015-03-27T13:20
at 2015-03-27T13:20
請教一個指令問題...
By Delia
at 2015-03-27T01:39
at 2015-03-27T01:39
awk與csh 搭配傳入外部變數的問題
By Oscar
at 2015-03-26T22:37
at 2015-03-26T22:37
ubuntu14.10 登入後黑屏
By Zora
at 2015-03-26T19:49
at 2015-03-26T19:49