我想匹配的模式和打印上面幾行,使用sed我能夠做到這一點,但在腳本中我不能通過。我得到下面它需要參數作爲命令如何避免這一點。sed無法識別的命令
這是我簡單的for循環腳本
#!/bin/sh
for i in `cat test.txt`
do
echo "***************************************************************************"
echo '\n'
echo $i
sed -n "'1,/$i/p' debug.log | tail -14"
echo '\n'
echo "***************************************************************************"
done
SED -n 「 '1/Ref555330/P' 的debug.log |尾-14」
Unrecognized command: '1,/Ref555330/p' debug.log | tail -14
請指導我解決這個線程。
什麼是'sed的-n「‘1/$ I/P’調試。日誌|尾巴-14「'應該這樣做? – anubhava 2014-10-16 19:08:48
它將從匹配的模式中打印上面的13行。 – 2014-10-16 19:10:15
您正在將sed「'1,/ $ i/p'debug.log | tail -14」作爲命令。刪除所有引號,並用雙引號包圍sed命令即「1,/ $ i/p」 – potong 2014-10-17 07:22:34