In this article, I will show you the command to swap the content of two text files in Power Shell. Swapping the content of two text files simply means replacing the content of file number one with the content of file number two and replacing the content of file number two with the content of file number one. Although the below command can easily swap the content of two text files it is not advisable to swap the content of large files that might caused a memory crash.
The content of the first text file before the swapping process is as follows:
> ${e:f1.txt} world hello!
The content of the second text file before the swapping process is as follows:
> ${e:f2.txt} hello world!
Next, let us start the swapping process:-
$ {e:f1.txt}, ${e:f2.txt} = ${e:f2.txt}, ${e:f1.txt}
Now let us view the contents of both text files again:
> ${e:f1.txt} hello world! > ${e:f2.txt} world hello!
As you can see the swap has indeed taken place as expected!