[Linux] Bash script 讀檔

摘要:[Linux] Bash script 讀檔

#! /bin/bash

filename=XXX

## 讀檔 word by word
for WORD in `cat $filename`
do
    echo $WORD
done


## 讀檔 line by line
while read LINE
do
    echo $LINE
done < $filename