Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
5 votes
1 answer
3k views

How to distinguish between a positional parameter and an option?

Both a positional parameter ($1, $2, and so forth) and an option (and/or argument) are written directly after a command, so what is the definition or phrasing to explain how to distinct them? In ...
user avatar
0 votes
1 answer
337 views

Create custom parameters (options) for already existing commands?

Recently I 've been wanting to create a custom parameter for pacman. To elaborate, I have tweaked pacman.conf so that specific packages (linux, linux-firmware, and a couple more) are ignored when I ...
Spyros's user avatar
  • 1
1 vote
1 answer
2k views

Bash get input while flag present?

I'm writing a bash script that has optional flags but also an input. I can't get the input as $1 because when flags are present the input is shifted. So for example if I run script.sh test then $1 ...
Philip Kirkbride's user avatar
3 votes
2 answers
1k views

Can a bash array be used in place of eval set -- "$params"?

I'm taking a look at the optparse library for bash option parsing, specifically this bit in the generated code: params="" while [ $# -ne 0 ]; do param="$1" shift case "$param" in --my-...
Wildcard's user avatar
  • 36.8k
7 votes
2 answers
7k views

Getopts option processing, Is it possible to add a non hyphenated [FILE]?

I'm using getopts for all of my scripts that require advanced option parsing, and It's worked great with dash. I'm familiar with the standard basic getopts usage, consisting of [-x] and [-x OPTION]. ...
J. M. Becker's user avatar
  • 4,949
5 votes
4 answers
941 views

How can I create a empty file whose name begins with a dash? [duplicate]

How can we create a empty file with the unix name -stuff. It means the name start with -. I tried with touch -stuff but it didn't work.
Elham abbasi's user avatar