Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

Scripting with Shell

20

Flashcards

0/20

Still learning
StarStarStarStar

Here Documents

StarStarStarStar

A type of redirection to feed a command list to an interactive program. Example: cat <<EOF Hello, World! EOF

StarStarStarStar

Conditional Expressions

StarStarStarStar

Used to perform actions based on different conditions. Example: if [ aeqa -eq b ]; then echo 'Equal'; fi

StarStarStarStar

Exit Status

StarStarStarStar

A numerical value returned by a command to indicate success or failure. Example: echo ?todisplaytheexitstatusofthelastcommandexecuted.? to display the exit status of the last command executed.

StarStarStarStar

String Test Operators

StarStarStarStar

Used for testing strings within conditional expressions. Example: if [ -z STRING];thenechoStringisempty;fiSTRING ]; then echo 'String is empty'; fi

StarStarStarStar

Case Statements

StarStarStarStar

Allow for a multi-way branch based on value of a variable. Example: case inputin1)echoOne;;)echoOther;;esacinput in 1) echo 'One';; *) echo 'Other';; esac

StarStarStarStar

Arithmetic Expansion

StarStarStarStar

Evaluate arithmetic expressions inside a script. Example: echo ((2+2))outputs4.(( 2 + 2 )) outputs 4.

StarStarStarStar

Loops

StarStarStarStar

Used for executing a block of commands repeatedly. Example: for i in {1..5}; do echo i;donei; done

StarStarStarStar

Command Substitution

StarStarStarStar

Allows the output of a command to replace the command itself. Example: CURRENT_DIR=(pwd)(pwd)

StarStarStarStar

Wildcards

StarStarStarStar

Used for pattern matching in file names. Example: ls *.txt lists all txt files in a directory.

StarStarStarStar

File Test Operators

StarStarStarStar

Used for testing properties of files and directories. Example: if [ -f FILE];thenechoFileexists;fiFILE ]; then echo 'File exists'; fi

StarStarStarStar

Alias

StarStarStarStar

Creates a shortcut for a longer command. Example: alias ll='ls -l'

StarStarStarStar

Pipelines

StarStarStarStar

Used to send the output of one command as input to another. Example: ls | grep 'txt'

StarStarStarStar

Script Arguments

StarStarStarStar

Access arguments passed to a bash script. Example: echo 1toaccessthefirstargument.1 to access the first argument.

StarStarStarStar

Variables

StarStarStarStar

A way to store data that can be used and manipulated within the script. Example: MY_VARIABLE='Hello, World!'

StarStarStarStar

Functions

StarStarStarStar

Reusable blocks of code that can be called multiple times within a script. Example: greet() { echo 'Hello, 1'; }

StarStarStarStar

Job Control

StarStarStarStar

Manage multiple jobs within a single Bash session. Example: Ctrl-Z to stop a job; fg to resume it.

StarStarStarStar

Redirection

StarStarStarStar

Used to change the standard input/output/error streams. Example: echo 'Hello' > hello.txt

StarStarStarStar

Parameter Expansion

StarStarStarStar

Expands variables and parameters to their values. Example: echo name:Anonymous{name:-'Anonymous'}

StarStarStarStar

Brace Expansion

StarStarStarStar

Used to generate arbitrary strings. Example: echo {A,B,C}{1,2,3} generates A1 A2 A3 B1 B2 B3 C1 C2 C3.

StarStarStarStar

Select Construct

StarStarStarStar

Creates a menu-driven interface for scripts. Example: select opt in 'Yes' 'No' 'Quit'; do break; done

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.