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
42
votes
9 answers

Python: How to make an option to be required in optparse?

I've read this http://docs.python.org/release/2.6.2/library/optparse.html But I'm not so clear how to make an option to be required in optparse? I've tried to set "required=1" but I got an error: invalid keyword arguments: required I want to make…
jack
  • 1,415
  • 4
  • 15
  • 22
42
votes
6 answers

Read arguments from command line - error TS2304: Cannot find name 'process'

Using TypeScript version 1.7.5. I am writing a nodeJS program in which I want to read in command line arguments passed by the user (2 integers). Everything works fine in raw JavaScript, but an issue arises with TypeScript. When process.argv is used…
Rohit Falor
  • 1,254
  • 2
  • 11
  • 17
42
votes
5 answers

find and replace in multiple files on command line

How do i find and replace a string on command line in multiple files on unix?
Vijay
  • 65,327
  • 90
  • 227
  • 319
41
votes
3 answers

Passing a tuple as command line argument

My requirement is to pass a tuple as command line argument like --data (1,2,3,4) I tried to use the argparse module, but if I pass like this it is receiving as the string '(1,2,3,4)'. I tried by giving type=tuple for argparse.add_argument, but is…
user1423015
  • 593
  • 1
  • 4
  • 12
40
votes
10 answers

Is it possible to accept custom command line parameters with Inno Setup

I am preparing an installer with Inno Setup. But I'd like to add an additional custom (none of the available parameters) command line parameters and would like to get the value of the parameter, like: setup.exe /do something Check if /do is given,…
Similar
  • 407
  • 1
  • 4
  • 4
39
votes
2 answers

Maximum number of Bash arguments != max num cp arguments?

I have recently been copying and moving a large number of files (~400,000). I know that there are limitations on the number of arguments that can be expanded on the Bash command line, so I have been using xargs to limit the numbers produced. Out of…
Lee Netherton
  • 21,347
  • 12
  • 68
  • 102
39
votes
3 answers

python argparse - either both optional arguments or else neither one

I have a program that uses a default name and password. I'm using argparse to allow the user to specify command line options, and I would like to enable the user to provide the program with a different name and password to use. So I have the…
tadasajon
  • 14,276
  • 29
  • 92
  • 144
38
votes
19 answers

Import SQL file by command line in Windows 7

I want to import an SQL file (size > 500MB) into a database. I have wamp on my PC. Phpmyadmin does not work well with this size. I changed all parameters in php.ini (max_upload_size etc.). But it does not work for me. So I want to import it by…
Nisarg
  • 3,024
  • 5
  • 32
  • 54
37
votes
2 answers

parse arguments after getopts

I want to call a bash script like this $ ./scriptName -o -p -t something path/to/file This is as far as I get #!/bin/bash o=false p=false while getopts ":opt:" options do case $options in o ) opt1=true ;; p )…
speendo
  • 13,045
  • 22
  • 71
  • 107
37
votes
2 answers

What is the difference between an inline variable assignment and a regular one in Bash?

What is the difference between: prompt$ TSAN_OPTIONS="suppressions=/somewhere/file" ./myprogram and prompt$ TSAN_OPTIONS="suppressions=/somewhere/file" prompt$ ./myprogram The thread-sanitizer library gives the first case as how to get their…
user1902689
  • 1,655
  • 2
  • 22
  • 33
37
votes
2 answers

Bash command line arguments, replacing defaults for variables

I have a script which has several input files, generally these are defaults stored in a standard place and called by the script. However, sometimes it is necessary to run it with changed inputs. In the script I currently have, say, three variables,…
Lanrest
  • 379
  • 1
  • 3
  • 6
36
votes
3 answers

Unable to pass '#' character as a command-line argument

I can't pass strings starting with # as command-line arguments. Here is a simple test: #include int main(int argc, char *argv[]) { for (int i = 1; i < argc; i++) printf("%s ", argv[i]); putchar('\n'); return 0; } If…
cd-00
  • 585
  • 5
  • 10
35
votes
1 answer

How to avoid pointer arithmetic when using char** argv

When trying to print the first command line argument: std::cout << argv[0] << std::endl; clang-tidy gives the warning: warning: 'do not use pointer arithmetic' from [cppcoreguidelines-pro-bounds-pointer-arithmetic] Is there an alternative…
35
votes
5 answers

Process command line arguments in go test

Is there a way to get the command line arguments in go "tests", When you call go test obviously your main is not run, so is there a way to process command line arguments, One way would be to use the flags packages and check for the command line…
Ali
  • 18,665
  • 21
  • 103
  • 138
34
votes
7 answers

How do you utilize more than 9 arguments when calling a label in a CMD batch-script?

I would like to know how to call more than 9 argument within a batch script when calling a label. For example, the following shows that I have 12 arguments assigned along with attempting to echo all of them. CALL:LABEL "one" "two" "three" "four"…
Anthony Miller
  • 15,101
  • 28
  • 69
  • 98