我想用shell腳本中的空字符串替換第一行?Shell腳本 - 如何用空字符串替換第一行字符串?
例如:
輸入
Skipping HTTPS certificate checks altogether. Note that this is not secure at all.
Line 2 ......
Line 3 ......
輸出
Line2
Line3
什麼Unix命令我可以用它來執行相同的?任何想法?
我想用shell腳本中的空字符串替換第一行?Shell腳本 - 如何用空字符串替換第一行字符串?
例如:
輸入
Skipping HTTPS certificate checks altogether. Note that this is not secure at all.
Line 2 ......
Line 3 ......
輸出
Line2
Line3
什麼Unix命令我可以用它來執行相同的?任何想法?
您可以使用下面也
yourcommand | awk 'NR>1'
或
yourcommand | tail -n+2
謝謝。 #2適合我。 –
#1有什麼問題嗎?讓我知道這個問題。我會糾正它。 –
我沒有嘗試第一個。我只用了第二個。 –
,如果它在一個文件,你可以用它來刪除第一行:
sed -i '1d' ../file.txt
感謝您的回覆。其實我正在考慮將它應用於由命令返回的字符串。 –
然後只是說'command | sed'1d'' – fedorqui
你的意思,你想輸出爲基本等於輸入,但被delted第一線?這是通過Unix命令'tail'完成的。
從尾部的手冊頁:
-n, --lines=K
output the last K lines, instead of the last 10; or use -n +K to output starting with
the Kth
您的輸入和輸出是從文件或命令的輸出? – Chris
看起來像第一行是有原因的!無論如何,你想要刪除該行的內容還是完全刪除?你在這裏嘗試了什麼,你卡在哪裏? –
這是來自命令輸出。 –