Shell 脚本读写文件的方法有很多种,下面是一些常见的方法:
cat filename.txt
echo "Content" > filename.txt
echo "Content" >> filename.txt
myvar=$(cat filename.txt)
while read line; do
echo $line
done < filename.txt
while read line; do
echo $line >> filename.txt
done < filename2.txt
wc -l filename.txt
awk '{print $NF}' filename.txt