简体   繁体   中英

Shell Script, file directory name as tabbable argument

Apologies in advance if my explanation comes off as poor, I have had a hard time putting this into words.

I have a shell script where I want to make the first argument that you pass into my script a tabbable argument. I want the argument to be a directory name that located in /opt/kickstart/html/sslroot/(Folder)

In other words, I want folder to be $1.

So far I have figured out that I can put a variable as var='/bin/ls /opt/kickstart/html/sslroot/' to display all the directorynames but I can't figure out much more than that.

Any help is appreciated!

Generally, you use set to set the argv arguments ( $1... ), so

#!/bin/bash

set -- hello world "$@"

echo "Argument 1: $1 | Argument 2: $2 | Arguments 3,5: $3, $5"
echo "all of the arguments: $*"

will yield

>./bla.bash bla and another argument here 1 3 2
Argument 1: hello | Argument 2: world | Arguments 3,5: bla, another
all of the arguments: hello world bla and another argument here 1 3 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM