referring to parent directory in a save file dialog

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?

1

2 Answers

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.

0

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.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like