Score:-1

Supposed to see '~' when listing file in directory

us flag

I'm working on a assignment for school and I'm having an issue getting this portion to work properly.

The assignment is having me create a file in the CLI, open and edit the file in GEDIT without saving, then list the directory. According to the instructions, when I list the directory, the file I have open and appended but unsaved should display a '~' after it but it's not showing up.

Am I missing something?

Frittierapparat avatar
us flag
Could you include the commands you used to create and edit that file?
hr flag
Whether or not such a file is created will depend on whether you have turned on the gedit "Autosave" feature I think ... I'm not sure whether it is on or off by default
KneadToKnow avatar
us flag
Are you listing the directory while the document is still open in GEDIT? When I first read through your question, I took "open and edit the file in GEDIT without saving" to mean "close GEDIT without saving the document," but I don't think that's the right interpretation. I think you should still have the document open in GEDIT when you list the directory.
Score:1
cn flag

Yes, you miss something: you do not expect to see that file when you first open it. You only will see it after you saved the file you opened.

How does gedit save files

The current file is renamed. Then the modified content is written out to a new file that is being given the name of the file you opened.

If in "Preferences", "Editor" tab, the option "Create a backup copy of file before saving" is enabled, the backup file is renamed by adding a ~ to the file name. Else, it is renamed to a random string starting with a dot .. That randomly named file is deleted if the save is successfull.

Contrast with behaviour of other, typical terminal based editors

This behaviour of the graphical editor Gedit (and other graphical editors) affects the working of hard links. As explained above, these editors actually save your modified content under a new file, i.e., a new inode. Linux hardlinks point to an inode. A hardlink to the same file elsewhere on the file system will continue to point to to the old data, and not anymore be linked to the changed file. Usually, this is not what users expect. However, this approach is safer: if the save fails, the original content is still preserved on disk.

Traditional (in particular terminal based) linux editors will save the updated content to the same inode. They write out the updated contents to the same inode, replacing the old content.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.