Views:
18,251β
Votes: 2β
Tags:
files
filesystem
swap
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1021774
Title:
How to merge a swap (.swp) file to the original file?
ID:
/2018/04/04/How-to-merge-a-swap-_.swp_-file-to-the-original-file_
Created:
April 4, 2018
Edited: June 12, 2020
Upload:
August 10, 2025
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
Direct answer
To technically answer your question:
cat test.out > experiment.out
cat .test.out.swp >> experiment.out
The first redirection of the cat
command >
creates a new file. The second redirection of the cat
command >>
appends to the existing file.
In reality experiment.out
probably wonβt be usable because you are adding an apple to an orange.
Alternative Repair
You can google repairing the files: Superuser.com How can I recover the original file from a .swpfile? In short use:
vim -r .swp
Make copies of all files first!
If that doesnβt work Iβd use gedit
on both files in separate tabs and then in a third tab paste text copied from the first two tabs.