Popular `shell` terminal commands

Append value(s) to an array

Loops through an array, running a command on each value.

Authored by: Wyatt-Stanke

Make a new, empty array

Makes an empty array and assigns it to variable "array_name"

Authored by: Wyatt-Stanke

Get number of elements in an array

Gets the number of elements in an array, and prints it to stdout.

Authored by: Wyatt-Stanke

Get a value from an array

Gets a value from an array and prints it to stdout.

Authored by: Wyatt-Stanke

Loop through an array and run a command on each value

Loops through an array, running a command on each value.

Authored by: Wyatt-Stanke

Set an index in an array to a value

Makes an empty array and assigns it to variable "array_name"

Authored by: Wyatt-Stanke

Chain commands together by forwarding output as input to the next command (pipe)

Executes command_1 and passes the output as input to command_2

Authored by: Mendel Cooper

Check if a file exists

Returns an exit code of 0 if the file exists.

Authored by: Sidratul Muntaha

Check if a file exists and is a regular file

Returns an exit code of 0 if the file exists and is a regular file (i.e. is not a directory or a symbolic link).

Authored by: Sidratul Muntaha

Check if a file exists and is directory

Returns an exit code of 0 if the file exists and is a directory.

Authored by: Sidratul Muntaha

Check if a number is greater than another number

Returns an exit code of 0 if integer_a is greater than integer_b.

Authored by: Sidratul Muntaha

Check if a number is greater than or equal to another number

Returns an exit code of 0 if integer_a is greater than or equal to integer_b.

Authored by: Sidratul Muntaha

Check if a number is less than another number

Returns an exit code of 0 if integer_a is less than or equal to integer_b.

Authored by: Sidratul Muntaha

Check if a number is less than or equal to another number

Returns an exit code of 0 if integer_a is less than or equal to integer_b.

Authored by: Sidratul Muntaha

Check if file exists and has a size greater than zero

Returns an exit code of 0 if the file exists and has a size greater than zero.

Authored by: Sidratul Muntaha

Check if file exists and is executable by the current process

Returns an exit code of 0 if the file is executable by the current process.

Authored by: Sidratul Muntaha

Check if file exists and is readable by the current process

Returns an exit code of 0 if the file is readable by the current process.

Authored by: Sidratul Muntaha

Check if file exists and is writable by the current process

Returns an exit code of 0 if the file is writable by the current process.

Authored by: Sidratul Muntaha

Check if string length is non-zero

Returns an exit code of 0 if the length of the string is non-zero.

Authored by: Sidratul Muntaha

Check if string length is zero

Returns an exit code of 0 if the length of the string is zero.

Authored by: Sidratul Muntaha

Check if two numbers are equal

Returns an exit code of 0 if the two integers are equal to each other.

Authored by: Sidratul Muntaha

Check if two numbers are not equal to each other

Returns an exit code of 0 if the two integers are not equal to each other.

Authored by: Sidratul Muntaha

Check if two strings are equal to each other

Tests if two strings are equal and returns an exit code of 0 if so.

Authored by: Sidratul Muntaha

Check if two strings are not equal to each other

Tests if two strings are not equal and returns an exit code of 0 if so.

Authored by: Sidratul Muntaha

Kill processes at port

Kill processes at a port.

Authored by: Maurice Gerhardt

List processes at port

List processes at a port to see if there are running processes.

Authored by: Maurice Gerhardt

Read file contents as input to another command

Reads the contents within file and passes it as input to the command.

Authored by: Mendel Cooper

Redirect output of command to a file

Writes the output of a command to a file, overwriting anything that was already in the file.

Authored by: Mendel Cooper

Redirect output of command to a file by appending

Redirects the output of the command to a file. Creates the file if not present, otherwise appends to it.

Authored by: Mendel Cooper

Redirect stderr

Executes the command, redirecting stderr to a file. Specify `/dev/null` to ignore stderr completely.

Authored by: Mendel Cooper

Redirect stdout

Executes the command, redirecting stdout to a file. Specify `/dev/null` to ignore stdout completely.

Authored by: Mendel Cooper

Search for specified file types and run a certain command for each file

Use the Find command to search for specified file types and run a certain command for each file

Authored by: funnyzak

Shell for-loop

A for loop that iterates through a sequence. A common example of this is to iterate through words in in a string, for example: for i in $( ls ); do echo item: $i done

Authored by: Mike G

Shell while-loop

A while loop, similar to one in other programming languages.

Authored by: Mike G