I was reading a shell script and I found the below command there. I tried searching on Google thinking attach, force and delete are the options used while running a script. But failed to find anything. Can anyone please explain what exactly the command below does? Please explain the usage of every single entity.

./filename.sh -attach -force -delete -ctxtype 1
  • 2
    hello, ./filename.sh is command, others are options to ./filename.sh. If you post contents of filename.sh, we can tell you what -attach, -force is doing in filename.sh – Jason Heo Nov 21 '13 at 10:27
  • ok, this simply means I have to somehow get that script file also to understand what options are doing. Thanks:) – Smith Nov 21 '13 at 10:31

First of all the script is invoked as ./filename.sh rather than filename.sh because the current directory (.) is not in the PATH by default in most distributions. In other words, if you give your shell a command name without a full path, it will not look for that command in the current directory. This is why the ./ part is needed.

As for -attach and co., they are, as you understand, options to the script. The operative word here is the. They are options used when running this script rather than when running a script. To understand what these options do, you need to look at the script itself and/or any documentation that came with it. You can try

./filename.sh -h

to see the help message if the script's author has provided any.

Finally, the lone 1 at the end is an argument. It may be an argument to the -ctxtype switch or, if that switch does not need an argument, then it's an argument to the script itself. Again, you have to look at the script itself to understand what each switch is supposed to do.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.