Score:0

referring to parent directory in a save file dialog

cn flag

I tired of the continuous updates in Windows making my programs unusable. After an excursion to Linux Lite, I am now running Ubuntu on my Dell laptop because it was the supported distro. I'm not TERRIBLY stupid, I can program in C and I remember things like file permissions (user-group-everyone) from my SCO days. However, something I tried to do didn't have the effect I thought.

I was in a file save dialog box, and I wanted to save the file to the parent directory without changing the current working directory, so I TRIED prefixing the file name with "dot dot backslash" to see if it would work (something from the good old days of PS-DOS).

Well, you know what happened. It hid the file in the current directory.

Is there no way of referring to the parent directory without entering the full path in the dialog if I do not want to change the working directory?

hr flag
The path separator in \*nix is *forward* slash, not backslash
Score:5
jp flag

Backslash has another meaning in Linux: it escapes the special meaning of a special character so that the literal character is used. For example . can mean the current directory or in some contexts 'any single character'. \. means a literal dot. Before a normal character, for example an ASCII letter, backslash makes no difference unless that character is also used to represent something else (e.g. \t is a tab and \n is a newline). When the character has no other meaning, for instance a, then escaping it has no effect: \a is a.

So

touch ..\asdf

will create the hidden file ..asdf. (It is enough with one dot in the beginning of the file name to hide it.)

Linux uses forward slash to separate between directory and file names in the path.

touch ../asdf

will create the file asdf in the parent directory.

Score:0
cn flag

You can get the parent directory using dirname function. For example:

parentdir=$(dirname `pwd`)

Test it by echo $parentdir

Without seeing your script I cannot advise how to use this function.

Arthur Grant avatar
cn flag
It was not in a script; I was in a file save dialog box, altering the filename attempting to say where I wanted the file. It was one of those nice things about DOS, because you did not have dialog boxes.
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.