The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

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.

⇧ Is systemctl daemon-reload equal systemctl restart service? How to fix the ubuntu splash loading bar showing up on the desktop view?  β‡©