how to echo whole string to a file?
Is there anyone know how to echo whole string to a file?
I am trying to echo the below sting into a file, but the output will be DATETIME=070620115242 DATETIME=`date +"%y%m%d%H%M%S"` Appreciate someone can help on this : ) |
Use the redirection operators > or >>. The latter will append to a file while the first will overwrite its contents:
DATETIME=`date +"%y%m%d%H%M%S"` echo DATETIME=$DATETIME > file.txt |
It still occurs the same output in the file "DATETIME=070620121353"
I need the below exact line exist in the file. DATETIME=`date +"%y%m%d%H%M%S"` Is there any way to do it? |
echo 'DATETIME=`date +"%y%m%d%H%M%S"`' > file.txt
notice both ` and ' were used |
Thanks a lot, it works now.
Appreciate your help so much : ) |
btw, "echo -n > filename" will empty the file.
|
All times are GMT -5. The time now is 01:12 AM. |