is there a way, when we use copy command on Linux :
$ cp ../dir_a/a.txt ../dir_b/a.txt
To name file a.txt to a.tmp.txt when copy start copying then renaming it automatically to a.txt original name when all the file is copied ? i have a java program that consume this file too fast before it is copied completely from share to share and thus note consuming all the file :
$ cp ../dir_a/a.txt ../dir_b/a.txt
$ ls ../dir_b/ #copying in progress
$ a.tmp.txt
$ ls ../dir_b/ #copying done
$ a.txt
Thank you,
Copy to the temporary name, then rename it. Renaming is atomic, so there won't be any partial contents.
cp ../dir_a/a.txt ../dir_b/a.txt.temp
mv ../dir_b/a.txt.temp ../dir_b/a.txt