1/41
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
stdin (0)
Default input source, usually the keyboard
stdout (1)
Default output destination, usually the screen
stderr (2)
Standard error output channel, used for error messages
>
redirects stdout to a file (overwrites file)
>>
Appends the stdout to a file
<
Redirects a file into stdin
2>
Redirects stderr to a file (overwrites file)
2>>
Appends stderr to a file
> file 2> &1
Redirects both stdout and stderr to the same file
/dev/null
A special file that discards all data written to it (“bit bucket”).
| (pipe operator)
Sends stdout of one command into stdin of another
head/tail
Display the first or last lines of a file
cut
Extrafcts specific columns or charcters from each line
tr
Translates or deletes characters (e.g., lowercase to uppercase).
sort
Sorts lines of text (with options like - r for reverse)
sed
Steam editor for filtering and transforming text
grep
Searches text using patterns or regular expressions
test command
Evaluates conditions and returns 0 (true) or 1 (false)
-f
Tests if a regular file exists
-d
Tests if a directory exists
-z
Checks if a string is empty
= / !=
Tests for string equality or inequality
-eq / -It / -gt
Tests for a string equality or inequality
if-then-else
Conditional statement that executes commands based on a test
case
Pattern-matching control structure for multiple options
while loop
Repeats commands while a condition is true
for loop
Iterates over a list of values
&&
Logical AND: RUNS SECOND COMMAND IF FIRST SUCCEEDS
||
Logical OR: runs second command if first fails
function_name() {}
Defines a resuable set of commands
return
Exits a function and returns a value
find [path] [criteria] [action]
Searches files and performs actions
-name “pattern”
Search by filename.
-type f / -type d
Search for files or directories
-mtime +30
Finds files modified more than 30 days ago.
-size +1M
Finds files larger than 1MB
-exec command {} ;
Executes a command on each file found
-delete
Deletes matching files
read
Reads input from the user or a file
$#
Number of positional parameters (arguments)
$0
Name of the script
$1, $2, …
Positional parameters passed to the script