简体   繁体   中英

Append text on a file in on bash script

I'm using cat to append some results in a file but the file its empty after the execution

start="$(date +'%s%3N')"
sleep 1
echo $par 
end="$(date +'%s%3N')"

duration=$(($end-$start))
cat  "$par $duration" >> result.dat

echo "$par $duration" >> result.dat

You use cat which will echo the content of the file with the name formed by "$par $duration" . This will most likely not exist, so that you end up appending nothing to result.dat.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM