shell scripting and bin folder
Hello chaps, I'm totally new to shell scripting and I'm reading a few tutorials. Now, they say that the script should be placed inside a bin folder and that often this folder needs to be created. I'm running ubuntu 12.04 and I do have this folder already and it's full of all sort of stuff from executables to whatnot. Now, one of the first things the tutorial said was to create an empty file inside the bin folder, with the following command
Code:
touch ~bin/datecp thanks |
I think you ought to look for a different tutorial. Creating scripts in /bin as you lern ks a stupid idea which could cause problems if you mess up.
|
Generally tutorials tell you to put a "bin" in your users home directory and append it to your users $PATH, not test scripts in /bin which is part of the systems $PATH.
The first lets you execute your new scripts from any location in the file system. The second is a recipe for disaster. You're doing the second. What I do is create a directory in which I work on scripts and go there to write and test them (at first). Once I know it executes more or less as I expected, I move it somewhere it can do some real damage (and append the somewhere to the system $PATH if I have to). Having the $PATH variable include your scriptorium is not really neccessary (or even desirable) during development. Untested scripts tend to have unintended consequences so a little care saves a lot of time. |
I think you missed a very important char:
that should be: ~/bin (that is a bin folder inside your home) |
thanks guys, I will create the new bin folder in my home directory then! One thing, I did change the permissions on the original bin folder though:
Code:
antobbo@antobbo-linux-Dell-System-XPS-L702X:/bin$ sudo chmod u+x ~bin/datecp thanks |
You're missing a critical "/" there. It should be ~/bin, not ~bin. And no, "chmod u+x ~bin" won't cause any problems.
|
thanks, no I'm not missing the /, I changed the permission of the default bin folder
|
so just check that tutorial again, that should be ~/bin. changing the permission of that bin folder is not recommended at all.
|
BIG difference between
Code:
echo ~bin Code:
echo ~/bin |
All times are GMT -5. The time now is 09:24 PM. |