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
682
votes
11 answers

Linux command to print directory structure in the form of a tree

Is there any linux command that I can call from a Bash script that will print the directory structure in the form of a tree, e.g., folder1 a.txt b.txt folder2 folder3
user243655
  • 7,749
  • 8
  • 30
  • 33
681
votes
21 answers

How do I parse command line arguments in Java?

What is a good way of parsing command line arguments in Java?
lindelof
  • 34,556
  • 31
  • 99
  • 140
681
votes
10 answers

How do I shutdown, restart, or log off Windows via a bat file?

I've been using Remote Desktop Connection to get into a workstation. But in this environment, I cannot use the power options in Start Menu. I need an alternative way to shutdown or restart. How do I control my computer's power state through the…
Keng
  • 52,011
  • 32
  • 81
  • 111
671
votes
12 answers

How to pretty print XML from the command line?

Related: How can I pretty-print JSON in (unix) shell script? Is there a (unix) shell script to format XML in human-readable form? Basically, I want it to transform the following: lorem ... into…
svidgen
  • 13,744
  • 4
  • 33
  • 58
658
votes
21 answers

How to prevent auto-closing of console after the execution of batch file

What command can I put at the end of a batch file to prevent auto-closing of the console after the execution of the file?
joe
  • 16,988
  • 36
  • 94
  • 131
652
votes
7 answers

What does the number in parentheses shown after Unix command names in manpages mean?

For example: man(1), find(3), updatedb(2)? What do the numbers in parentheses (Brit. "brackets") mean?
duckyflip
  • 16,189
  • 5
  • 33
  • 36
648
votes
12 answers

How do I specify a password to 'psql' non-interactively?

I am trying to automate database creation process with a shell script and one thing I've hit a road block with passing a password to psql. Here is a bit of code from the shell script: psql -U $DB_USER -h localhost -c"$DB_RECREATE_SQL" How do I pass…
Alex N.
  • 14,805
  • 10
  • 46
  • 54
643
votes
7 answers

Run R script from command line

I have a file, called a.r, it has a chmod of 755, sayHello <- function(){ print('hello') } sayHello() How can I run this via command-line?
Sait
  • 19,045
  • 18
  • 72
  • 99
638
votes
26 answers

How can I get a recursive full-path listing, one line per file?

How can I spit out a flat list of recursive one-per-line paths? For example, I just want a flat listing of files with their full…
dreftymac
  • 31,404
  • 26
  • 119
  • 182
620
votes
11 answers

How do I access command line arguments?

I use python to create my project settings setup, but I need help getting the command line arguments. I tried this on the terminal: $python myfile.py var1 var2 var3 In my Python file, I want to use all variables that are input.
ParisNakitaKejser
  • 12,112
  • 9
  • 46
  • 66
616
votes
35 answers

How can I create an empty file at the command line in Windows?

How can I create an empty file at the DOS/Windows command-line? I tried: copy nul > file.txt But it always displays that a file was copied. Is there another method in the standard cmd? It should be a method that does not require the touch command…
Grendler
  • 6,327
  • 3
  • 16
  • 8
609
votes
24 answers

How to count total lines changed by a specific author in a Git repository?

Is there a command I can invoke which will count the lines changed by a specific author in a Git repository? I know that there must be ways to count the number of commits as Github does this for their Impact graph.
Gav
  • 11,062
  • 7
  • 33
  • 35
608
votes
17 answers

How to colorize diff on the command line

When I have a diff, how can I colorize it so that it looks good? I want it for the command line, so please no GUI solutions.
daniel kullmann
  • 13,653
  • 8
  • 51
  • 67
603
votes
30 answers

How can you find and replace text in a file using the Windows command-line environment?

I am writing a batch file script using Windows command-line environment and want to change each occurrence of some text in a file (ex. "FOO") with another (ex. "BAR"). What is the simplest way to do that? Any built in functions?
Ray
  • 187,153
  • 97
  • 222
  • 204
599
votes
21 answers

How to run SQL script in MySQL?

I want to execute a text file containing SQL queries, in MySQL. I tried to run source /Desktop/test.sql and received the error: mysql> . \home\sivakumar\Desktop\test.sql ERROR: Failed to open file '\home\sivakumar\Desktop\test.sql', error:…
user1160432
  • 6,091
  • 3
  • 14
  • 4