read 讀取文件并將一行中的不同字段存儲至不同變量中;
比如說:
cat test
zhang? ? 10? ? 155
wang? ? 8? ? 148
可以用?
read? name? age? height? <? test
即將每一行的三個值分別儲存到變量中,方便應(yīng)用在循環(huán)或條件語句,或 awk 的使用中。
或者:
cat? test? |??
while? read??name? age? height?
do
...
done
也可以通過讀取文件應(yīng)用到循環(huán)中。
while read chr start end mid
do
? ? echo "geom_rect(aes(xmin="$chr"+1.3, xmax="$chr"+1.6, ymin="$start", ymax="$end"), fill=\"#AD7CF7\") + \n "
? ? echo "annotate(\"text\", x="$chr"+1.45, y="$mid", label=1, color=\"black\", size=3) +? "
done < lao.txt > output_file.R
# 讀取 lao.txt 文件中的行批量生成繪圖腳本。