簡體   English   中英

Shell 腳本,文件目錄名稱作為可選項卡參數

[英]Shell Script, file directory name as tabbable argument

如果我的解釋很糟糕,請提前道歉,我很難用語言表達。

我有一個 shell 腳本,我想在其中將傳遞給我的腳本的第一個參數設為可選項卡參數。 我希望參數是位於 /opt/kickstart/html/sslroot/(Folder) 中的目錄名稱

換句話說,我希望文件夾為 1 美元。

到目前為止,我已經發現我可以將一個變量作為 var='/bin/ls /opt/kickstart/html/sslroot/' 來顯示所有目錄名,但我想不出更多。

任何幫助表示贊賞!

通常,您使用set來設置 argv 參數( $1... ),所以

#!/bin/bash

set -- hello world "$@"

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

將產生

>./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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM