2022年7月9日星期六

shell script 一行一行讀檔案,並且以變數方式印出

 假設有個檔案file_list.txt,內容如下:
# cat file_list.txt
1111
2222
3333

範例如下:

================== echo_value_from_file.sh ==================

#!/bin/sh
echo_file() {
    exec < "file_list.txt"
    while read want_param    #把檔案內的值,assing給want_param參數
    do
            echo $
want_param
    done
}
echo_file

========================================================

執行結果如下:








沒有留言:

發佈留言

使用 lsblk 印出 emmc 每個 partition的"名字"與"size"

使用以下的command可以印出 eMMC的 partition資訊 lsblk --bytes --output name,partlabel,size   參數說明 --bytes: partition的大小,以byte的方式輸出 --output: 後面可以指定要輸出的內容...