1

I was ssh'ing into a Raspberry Pi running Raspbian, editing a file with nano, when I lost my internet connection (by leaving the WiFi zone). After reconnecting an hour later, I found that the pi had kicked me out, but after logging back in, I saw that it did not stop the task. When I reopened nano, it told me that the file was being edited by the previous nano process, and it gave me the PID. I made substantial changes to the file and forgot to save, but presumably the changes are still there.

How can I tell nano to save & quit (^O -> Enter -> ^X) or reopen the task in a new shell, from outside the original process?

9
  • 3
    It's unlikely you'll be able to reattach to that session, or send it anything meaningful. If nano 'knows' that the file is open, there's a good chance that the temporary save has been written somewhere and this serverfault answer may be how you are required to resolve this: serverfault.com/questions/453703/… May 3, 2018 at 21:12
  • 1
    One of nano’s online man pages indicates it will write buffers out to files named nano.save if it receives a HUP or TERM signal. Test on an innocent file first!
    – Jeff Schaller
    May 3, 2018 at 21:16
  • maybe this link will help you : unix.stackexchange.com/questions/31824/… May 3, 2018 at 21:16
  • I see a <myfile.py.save> file in my directory, thanks @JeffSchaller, would you like to write an answer?
    – AAM111
    May 3, 2018 at 21:17
  • I would, but cannot right now. Please feel free to do so yourself.
    – Jeff Schaller
    May 3, 2018 at 21:33

1 Answer 1

2

In the comments, @JeffSchaller noted that a terminated nano process saves the unwritten file in file_path.extension.save.

If it is there, which it was for me, it is a simple matter of mving the file into its original name.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .