Questions tagged [command-line]

A command line is a string given to a command interpreter that tells it actions to take, such as running programs or copying files. The interpreter processes command lines with escapes and substitutions.

A command-line interface () is a mechanism for interacting with a computer operating system or software by typing commands to perform specific tasks. This text-only interface contrasts with the use of a mouse pointer with a graphical user interface (GUI) to click on options, or menus on a text user interface (TUI) to select options.

This method of instructing a computer to perform a given task is referred to as entering a command. The system waits for the user to conclude the submitting of the text command by pressing the Enter key (a descendant of the carriage return key of a typewriter keyboard). A command-line interpreter then receives, parses, and executes the requested user command. The command-line interpreter may be run in a text terminal or in a terminal emulator window as a remote shell client such as .

Upon completion, the command usually returns output to the user in the form of text lines on the CLI.

Related tag:

See also: Wikipedia Command-line_interface.

23435 questions
1152
votes
9 answers

List all environment variables from the command line

Is it possible to list all environment variables from a Windows' command prompt? Something equivalent to PowerShell's gci env: (or ls env: or dir env:).
Nicola Cossu
  • 54,599
  • 15
  • 92
  • 98
1152
votes
9 answers

How to iterate over arguments in a Bash script

I have a complex command that I'd like to make a shell/bash script of. I can write it in terms of $1 easily: foo $1 args -o $1.ext I want to be able to pass multiple input names to the script. What's the right way to do it? And, of course, I…
Thelema
  • 14,257
  • 6
  • 27
  • 35
989
votes
2 answers

How can I get the current date and time in the terminal and set a custom command in the terminal for it?

I have to check the time in a Linux terminal. What is the command for getting date and time in a Linux terminal? Is there a way in which we can set a custom function?
harshal
  • 10,252
  • 3
  • 18
  • 23
969
votes
7 answers

How do I get the application exit code from a Windows command line?

I am running a program and want to see what its return code is (since it returns different codes based on different errors). I know in Bash I can do this by running echo $? What do I do when using cmd.exe on Windows?
Skrud
  • 11,604
  • 5
  • 24
  • 22
923
votes
22 answers

Use grep --exclude/--include syntax to not grep through certain files

I'm looking for the string foo= in text files in a directory tree. It's on a common Linux machine, I have bash shell: grep -ircl "foo=" * In the directories are also many binary files which match "foo=". As these results are not relevant and slow…
Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
856
votes
19 answers

How to force cp to overwrite without confirmation

I'm trying to use the cp command and force an overwrite. I have tried cp -rf /foo/* /bar, but I am still prompted to confirm each overwrite.
Thiyagarajan Varadharaj
  • 10,154
  • 5
  • 21
  • 18
828
votes
24 answers

How can I reverse the order of lines in a file?

I'd like to reverse the order of lines in a text file (or stdin), preserving the contents of each line. So, i.e., starting with: foo bar baz I'd like to end up with baz bar foo Is there a standard UNIX commandline utility for this?
Scotty Allen
  • 12,897
  • 9
  • 38
  • 51
828
votes
7 answers

How to redirect Windows cmd stdout and stderr to a single file?

I'm trying to redirect all output (stdout + stderr) of a Windows command to a single file: C:\>dir 1> a.txt 2> a.txt The process cannot access the file because it is being used by another process. Is it possible, or should I just redirect to two…
ripper234
  • 222,824
  • 274
  • 634
  • 905
791
votes
22 answers

How can I read and process (parse) command line arguments?

In Python, how can we find out the command line arguments that were provided for a script, and process them? Related background reading: What does "sys.argv[1]" mean? (What is sys.argv, and where does it come from?). For some more specific…
edgerA
763
votes
16 answers

Run Command Prompt Commands

Is there any way to run command prompt commands from within a C# application? If so how would I do the following: copy /b Image1.jpg + Archive.rar Image2.jpg This basically embeds an RAR file within JPG image. I was just wondering if there was a…
user
  • 16,429
  • 28
  • 80
  • 97
738
votes
17 answers

Run a PostgreSQL .sql file using command line arguments

I have some .sql files with thousands of INSERT statements in them and need to run these inserts on my PostgreSQL database in order to add them to a table. The files are that large that it is impossible to open them and copy the INSERT statements…
CSharpened
  • 11,674
  • 14
  • 52
  • 86
712
votes
9 answers

Node.js version on the command line? (not the REPL)

I want to get the version of Node.js on the command line. I'm expecting to run a command like: node -version but that doesn't work. Does anybody know what the command line would be? (i.e. not the REPL)
hawkeye
  • 34,745
  • 30
  • 150
  • 304
706
votes
22 answers

Adding a directory to the PATH environment variable in Windows

I am trying to add C:\xampp\php to my system PATH environment variable in Windows. I have already added it using the Environment Variables dialog box. But when I type into my console: C:\>path it doesn't show the new C:\xampp\php…
Netorica
  • 18,523
  • 17
  • 73
  • 108
702
votes
32 answers

How to check Django version

I have to use Python and Django for our application. So, I have two versions of Python, 2.6 and 2.7. Now I have installed Django. I could run the sample application for testing Django succesfuly. But how do I make sure whether Django uses the 2.6 or…
maheshgupta024
  • 7,657
  • 3
  • 20
  • 18
695
votes
14 answers

How can I use grep to find a word inside a folder?

In Windows, I would have done a search for finding a word inside a folder. Similarly, I want to know if a specific word occurs inside a directory containing many sub-directories and files. My searches for grep syntax shows I must specify the…
kiki
  • 13,627
  • 17
  • 49
  • 62