Given a .txt files with space separated words such as:
But where is Esope the holly Bastard
But where is
And the Awk f
Just use shell redirection :
echo "test" > overwrite-file.txt
echo "test" >> append-to-file.txt
A useful command is tee
which allow to redirect to a file and still see the output :
echo "test" | tee overwrite-file.txt
echo "test" | tee -a append-file.txt
I see you are working with asian script, you need to be need to be careful with the locale use by your system, as the resulting sort might not be what you expect :
* WARNING * The locale specified by the environment affects sort order. Set LC_ALL=C to get the traditional sort order that uses native byte values.
And have a look at the output of :
locale