Questions tagged [arguments]
An argument is usually defined as the actual value passed to a function, procedure, or command line program.
529 questions
3
votes
3
answers
979
views
How do I ensure a bash script argument is a specific value?
The following script is supposed to check $1 and see if it is a specific value. It only works when one Bash [[... =~ ...]] regex check is passed in an if statement.
The error is: When more than one ...
1
vote
4
answers
262
views
Need shell script help - processing the same option multiple times
So I've ran into a bit of a wall, I have an option in my script that calls a function which allows me to specify a file/directory and then I want to parse that output into a menu tool (using dmenu in ...
5
votes
4
answers
1k
views
Pass multiple files as a single option
I'm trying to build a wrapper to execute a tool multiple times, then concatenate some of the results. I'd like to pass two sets of files to my wrapper script, then run the tool for each pair of files. ...
2
votes
0
answers
84
views
In the context of {ARG_MAX}, how robust is `find . -exec sh -c 'exec tool "$@" extra-arg' find-sh {} +`?
Suppose I want to do this:
find . -exec tool {} extra-arg +
It doesn't work and I know why: -exec … {} + does not allow extra-arg(s) between {} and +. So be it. It seems I can inject the extra-arg by ...
0
votes
1
answer
76
views
Can we pass directory list from find command as argument to another find command and execute md5sum?
I want to list all the directories in present directory and pass those directories as a argument to another find command
The below example will explain it correctly.
$ find . -maxdepth 1 -type d
.
./...
0
votes
1
answer
222
views
Manipulating arguments with OPTIND, OPTARG, getopts, and shift correctly
My small POSIX shell scripts do not usually take any arguments, so this is kind of new to me...
The minimal snippet would probably look like this:
# default for hotkey variable on top of script is set
...
0
votes
1
answer
93
views
getopt with several `--`
I have a script with this usage:
myscript [options] positional-args... -- [fwd-params]
Because [options] can have long, or short variants, I like using getopt. But I'm having troubles.
I use getopt ...
3
votes
1
answer
703
views
tcsh: Handle spaces in arguments when passing on to another command
I wrote a script that needs to call a command and pass on arguments. My script has its own parameters but some need to be passed through. This fails when arguments to my script have spaces in them.
...
0
votes
2
answers
196
views
Is it possible to use a command with an argument to trigger a bash alias?
I have a program that tries to trigger a screenlock using the following commands:
xdg-screensaver lock
xscreensaver -lock
cinnamon-screensaver-command --lock
The problem is that I'm using ...
2
votes
2
answers
798
views
bash: if $i equals any command line argument: if [[ " $@ " =~ " $i " ]]
To check if $i equals any command line argument (in a Bash script), I use
if [[ " $@ " =~ " $i " ]]
Is there a better way?
I mean, a way that is more recommendable, more general, ...
1
vote
1
answer
524
views
Bash parameter substitution with multi line error message
I'm using parameter substitution with an error message, such as ${var1:?'some message'}. I've incorporated a multi-line error message. Presently, it only functions properly when enclosed within single ...
1
vote
2
answers
247
views
Hide single argument from bash history
Is there a way to hide a single argument passed into the terminal, but still pass the argument to the command?
This question addresses the problem of passing a plain-text password through the shell.
...
2
votes
1
answer
304
views
script arguments in bash
I am working on a a script that need to take two script arguments and use them as variables in the script. I couldn't get this working and unable to find out what I am doing wrong. I see the issue is ...
0
votes
2
answers
338
views
Pass multiple arguments from single line from a text file to teminal
I have a python program that requires 2 arguments input-file and output-file.
It reads input-file and creates a copy of that file with some modifications in the output-file.
I created a text file with ...
2
votes
4
answers
3k
views
Stuck at passing JSON as argument in bash
I know many have asked similar questions, but I can't make it work.
I have a file called Dependencies:
Accounts
Aggregates
Blog
Configuration
Contacts
Contents
DataTypes
Forms
Geo
Globalization
Media
...