Questions tagged [command-line-arguments]

Programming command line utilities that take parameters.

This tag should have questions relating to programming command-line utilities that take arguments.

A command line argument is a parameter passed to a command line program. For instance git status is the Git command line program with the parameter status. Git then acts accordingly to that parameter.

Command line arguments are used in command line programs from the Command Prompt on Windows, a shell on Unix and the Terminal program on Mac OS. These are not visual GUI programs, they are text based.

Learn more: Wikipedia Article Command Line

5018 questions
2
votes
2 answers

Bash Script: options - case: range of multiple numbers

I'm working on a script in Linux Bash, with different kinds of options to use. Basically, the program is going to ping to the given ip-address. Now, I want to enable the user to write a range of ip-adresses in the terminal, which the program then…
2
votes
1 answer

Passing command line argument from the terminal with apostrophe or quote

I have seen questions about passing arguments with quotes to a shell script (e.g., this question). My situation is slightly different: I am passing an argument to my java program from the bash terminal. The number of possible arguments is finite…
Chthonic Project
  • 8,216
  • 1
  • 43
  • 92
2
votes
2 answers

How to pass VmOptions to AndroidStudio via command line arguments?

quick version: I want to pass studio.vmoptions arguments to while executing studio.sh directly on the command line, instead of the actual vmoptions file. Is it possible? How? for example, something like ./studio.sh -Dhidpi=true. use case: latest…
Budius
  • 39,391
  • 16
  • 102
  • 144
2
votes
0 answers

Repeated option groups with Commons CLI?

I have a specific set of requirements for parsing command line options. My intent is not unlike the Linux beep command, in which you can specify multiple beeps of different frequencies and durations. I just happen to be working with 4-bit…
DigitalMan
  • 2,440
  • 5
  • 26
  • 32
2
votes
3 answers

What are some use cases of "$*" in bash?

From the bash man page: "$*" is equivalent to "$1c$2c...", where c is the first character of the value of the IFS variable. "$@" is equivalent to "$1" "$2" ... Any example where "$@" cannot work in place of "$*"?
Deepak
  • 575
  • 1
  • 5
  • 13
2
votes
1 answer

Registry command entry isn't running like it runs in command line

My question clarified is, "What's different about running a command from within the registry at command line compared to running the same command from in a command line? Then how do I make it the same to work the way I want?" Information about my…
2
votes
3 answers

C# Redirecting process results to a text file

I've been racking my brain trying to figure out why I can not use >> (append) as a part of my p.StartInfo.Argument. When I remove ">" it works perfectly, but the moment I try to use ">" or ">>" I get a "Incorrect Parameter" error. I've gone ahead…
snapplex
  • 851
  • 3
  • 13
  • 27
2
votes
1 answer

Sed error "sed: no input files"

I have the script which cleans up the the pattern in the file supplied as the argument. The "file1" that needs clean up and the script lies at the same place.When I pass "file1" as argumenit is echoed well but at the time of the execution of the…
user3616128
  • 357
  • 2
  • 5
  • 19
2
votes
1 answer

Argparse: Optional arguments, distinct for different positional arguments

I want to have positional arguments with an optional argument. Smth like my_command foo --version=0.1 baz bar --version=0.2. That should parse into a list of args [foo, bar, baz] with version set for 2 of them. Without optional argument it's trivial…
Kirill Zaitsev
  • 4,511
  • 3
  • 21
  • 29
2
votes
2 answers

Comparing command line arguments reference return false while array of String return true

Currently i am working with String manipulation and while doing demo i have found some different behaviour. Below is my code. public class HelloWorld{ public static void main(String []args){ String str1 = "Hello"; String str2 = "Hello"; …
Pratik
  • 944
  • 4
  • 20
2
votes
1 answer

Naming flags, best practices

When naming command-line flags, and flags in general what's the best practice regarding flags that disable things? Should I be going for something like: --disable-thinging or --no-thinging
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
2
votes
3 answers

Terminal shell: How to use echo instead of a text file as command-line arguments

I have a command line utility which needs a text file (to format the output) as argument. I only need the pure value and no formatting, so I'd like to have a one-line script to get the value. The text file template.file only contains: $1 Here's an…
2
votes
2 answers

Why does sh/bash set command line parameter values when trying to set environment variable?

A question on basics : While tuning environment variables for a program launched from a script, I ended up with somewhat strange behaviour with sh (which seems to be actually linked to bash) : variable setting seems to mess up with command-line…
Touko
  • 11,359
  • 16
  • 75
  • 105
2
votes
2 answers

Memory Management Command Line Arguments in C

I am writing a simple program that takes the command line arguments and stores them into a char **. I am trying to learn more about memory management but cannot get past this simple stumbling block. My program is supposed to copy the command line…
user2455869
  • 151
  • 1
  • 13
2
votes
2 answers

Iterative command line arguments in Python

I am working on Python 2.7.9 and using argparse module for command line arguments. I want to extend my code such that it should be able to take the command line arguments depending on the arguments already given by the user in the same command line.…
Vipul
  • 125
  • 2
  • 11