문제

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!

도움이 되었습니까?

해결책

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.

다른 팁

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

try this approach :

 while read user pass;do 
    echo "$user,$pass"
    # do encrypt or other operation before echo 
  done <configfile >configfile.new
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top