如何從管道中獲取特定行,然後在末尾回顯它們。爲了說明我的意思 - 我已經通過管道發送和proccesing這樣如何在bash shell中選擇特定行和回顯結尾
#!bin/bash
while read line; do
echo "$line"
done
我有這個輸入
foo1 -> long
foo1 -> hell
foo1 -> fail
foo1
fast1 -> fine
fast1 -> good
fast1
我需要這樣做
foo1 -> long
foo1 -> hell
foo1 -> fail
fast1 -> fine
fast1 -> good
fast1
foo1
只是一個例子幾行 - 將有更長的輸入處理
您需要能夠將不喜歡的行存儲到數組或其他東西中,然後在最後遍歷該結構。這可能是一個有用的起點:http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_10_02.html – mattwise