Results 1 to 3 of 3
Okay, well I'm writing a script that has the simple task of downloading an archive, making a directory, and extracting the archive to that directory. The part I'm having trouble ...
- 04-06-2008 #1
Writing a script for more than one user
Okay, well I'm writing a script that has the simple task of downloading an archive, making a directory, and extracting the archive to that directory. The part I'm having trouble with is writing the part that tells the computer to make a directory. If it were for me alone, I could simply tell it...
However, I know that each time it will be used, the user will not be "justin". What could I do to make this command work for anyone that decided to use it? Thanks for any help in advance.Code:mkdir /home/justin/.kde/share/apps/deKorator/themes/

P.S. I am doing this for multiple purposes. The first being for my own convenience (now and possibly in the future), and for educational purposes (I'm new to writing scripts. I know what to do, but not all the commands). It's basic function will be to install a specific deKorator theme for the user, and also install deKorator and set it up the themes directory (which it doesn't seem to do on it's own).
EDIT:I just figured it out....I googled it (was trying to before) and found I wasn't asking the right question. I could make said line I mentioned before as
Code:mkdir $HOME/.kde/share/apps/deKorator/themes/
- 04-07-2008 #2Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
I am glad that you found your way by yourself.
I will just add a little tip: when using file and directory names under bash, remember that in linux, names with blank spaces are legal.
Having a space in your home directory is not usually a good idea, but it's not impossible. So, just to be on the safe side, you should always use double quotes when writing paths of file names, like this:
You can just quote the unknown part, since the rest of the string is well known and you are sure that it doesn't contain spaces:Code:mkdir "$HOME/.kde/share/apps/deKorator/themes/"
If you don't quote this, and your home dir is called "Jean Paul", then mkdir will receive two arguments, the first will be "Jean", the second would be "Paul/.kde/share/apps/deKorator/themes/" and you will get "inexplicable" errors.Code:mkdir "$HOME"/.kde/share/apps/deKorator/themes/
That's very unprovable in this case, but since failures in the quotation are one of the most common errors amongst newcomers, I just wanted to let you know about it so you don't get the bad habit.
- 04-07-2008 #3
i92 makes an excellent point about quoting, and it is a good one to remember.
I just want to add that because using your home directory is so common, Bash actually has a shortcut for this: '~' (which you also don't have to quote, which is nice). So your line could also be:
And this would be the same as using "$HOME".Code:mkdir ~/.kde/share/apps/deKorator/themes/
DISTRO=Arch
Registered Linux User #388732


Reply With Quote
