简体   繁体   English

Shell 脚本,文件目录名称作为可选项卡参数

[英]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.我有一个 shell 脚本,我想在其中将传递给我的脚本的第一个参数设为可选项卡参数。 I want the argument to be a directory name that located in /opt/kickstart/html/sslroot/(Folder)我希望参数是位于 /opt/kickstart/html/sslroot/(Folder) 中的目录名称

In other words, I want folder to be $1.换句话说,我希望文件夹为 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.到目前为止,我已经发现我可以将一个变量作为 var='/bin/ls /opt/kickstart/html/sslroot/' 来显示所有目录名,但我想不出更多。

Any help is appreciated!任何帮助表示赞赏!

Generally, you use set to set the argv arguments ( $1... ), so通常,您使用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: $*"

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将脚本文件重命名为目录名称的Shell脚本 - Shell Script to Rename an Image File To the Directory Name Shell脚本修改具有同一目录中多个文件的文件名的变量 - Shell script to modify variable with file name of multiple files in same directory 如何编写一个带有一个参数的bash shell脚本(目录名) - How to write a bash shell script which takes one argument (directory name) 如何编写一个以数据文件名作为参数来运行我的 perl 脚本的 shell 脚本? - How do I write a shell script that takes a data file name as an argument to run my perl script? 对脚本文件的参数中给定目录中的所有文件运行cat命令,并以名称作为第二个参数输出 - run cat command for all the files in the directory given in argument of the script file and out put with the name given as second argument shell脚本:检查目录名称并转换为小写 - shell script: check directory name and convert to lowercase "<i>Assume the file name is given as command line argument.<\/i>假设文件名作为命令行参数给出。<\/b> <i>Write a shell script to count lines, characters and words<\/i>编写一个shell脚本来计算行数、字符数和单词数<\/b>" - Assume the file name is given as command line argument. Write a shell script to count lines, characters and words 我想创建一个shell脚本,它将创建一个预先格式化的文件,并使用文件名作为参数在vim中打开它 - I want to create a shell script that will create a pre-formatted file and open it in vim using a file name as an argument Shell脚本:检查文件是文件而不是目录 - Shell script: Check that file is file and not directory 用点创建的目录名,使用 shell 脚本 - Directory name created with a dot ,using shell script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM