I would like to export an encrypted string to a file that already has some content.
How can i delete the content of this file and add my string?
I tried cat but that did not work. Thanks for your help!
Use the > redirection operator, it will wipe out the target file. Use the >> to append to the end of the target file
cat encrypted_file.txt > desired_file.txt
In Bash you can easily redirect a string into a file with bash like this
echo "This is my string" > filename
A single >
will replace the contents, >>
will append the string to the end of the file.
For more information have a look at the bash manual regarding Redirection.
try this approach :
while read user pass;do
echo "$user,$pass"
# do encrypt or other operation before echo
done <configfile >configfile.new