Shell Scripting Arguments help needed bad
I've been trying to do arguments for the longest time and I just need a straight answer on how to apply them on scripts and how to run a specific argument for example this is what I have to do
Modify the script file now stored in your bin folder so that it accepts an arguement The new arguement will be a path for a folder you want backed up Your script will replace each instance of /var with that arguement You should be able to run your script from anywhere in Linux and have it backup to a set location Alter your filename so that your path becomes a part of it, along with the date Just show how to do it and how to run that specific argument please. PS Im running on Linux Ubuntu I dont know if it makes a difference. |
If even after "the longest time" you still have no idea how to grab a command line argument from within a script, then I'm afraid nobody can help you. You need to put forth some effort of your own and show us where you're stuck in order to get any help. We won't do your homework for you.
http://www.linuxquestions.org/questi...27-4175523395/ And a simple Google search for "bash command line arguments" returns these handy references: http://www.tldp.org/LDP/abs/html/ http://how-to.wikia.com/wiki/How_to_..._a_bash_script http://linuxcommand.org/wss0130.php http://linuxconfig.org/bash-scripting-tutorial http://www.ibm.com/developerworks/library/l-bash2/ |
Then teach me just show me some examples please.
|
There are plenty of examples in the five links I just gave you, which I found with a 1 second Google search (along with hundreds more).
As I said before Quote:
|
Instead of the echo how do I put a command like do I just type it.
|
Quote:
On the other hand, since the question implies that this is one step in a series (i.e. "Modify the script file now stored in your bin folder..."), it seems to indicate that you may not have performed the previous steps which probably would have taught you how to perform this step... Either of those behaviors are not beneficial for you, or those who might try to help you. But, if you are really trying to learn how this works, a good place to begin (in addition to all the links provided by suicidalegroll) would be here: Bash Guide for Beginners. For your specific needs, read down to Section 3.2.5 - Special parameters, and in particular, positional parameters. For an example, say that you have a script named myscript, which takes a path argument, you would run it like this... Code:
myscript /path/to/something Code:
#!/bin/bash |
Still don't understand
|
Still not trying
|
Quote:
Please clarify what you are having trouble understanding. and show us your work before we got involved. |
I am I have been trying for a month all those links you posted I have beem there they do not answer my question
|
Habitual Im having trouble on putting a argument inside a script I dont know the commands and how to run the arguments.
|
If you honestly cannot find the solution from any of the links provided, my suggestion would be to quit this course as you are not suited.
As you have found, no one here is going to do the work for you, although in saying that I am not sure what else you would like from astrogeek's example. You may also wish to go an re-read (as I assume you have already read them once) the LQ rules that states: Quote:
|
I understand about the whole not doing your homework. What I need is just examples of it just show me one example on amything but on the topic on how to use arguments. I aint asking for no answer but an example.
|
As I asked once already, show us the script in your bin directory/"folder".
I'm sensing a pattern to this thread. But it could be just "me". I'm old and tired ;) Quote:
Here's a basic argument script: Code:
#!/bin/bash |
Quote:
|
All times are GMT -5. The time now is 12:30 PM. |