User Tools

Site Tools


ops102:bash_scripting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ops102:bash_scripting [2024/03/07 21:36] chrisops102:bash_scripting [2024/04/16 18:10] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== NOTE: This page is being edited and is NOT ready for use. ===== 
- 
 ====== Bash Scripting ===== ====== Bash Scripting =====
  
Line 176: Line 174:
 ===== Command Capture ===== ===== Command Capture =====
  
-You can capture the output (stdout) of a command as a string using the notation ''$( )''and then use that string in a variable assignment or as a command argument:+You can capture the output (stdout) of a command as a string using the notation ''$( )'' and then use that string in a variable assignment or as a command argument:
  
   $ echo "The current date and time is: $(date)"   $ echo "The current date and time is: $(date)"
Line 521: Line 519:
   #!/usr/bin/bash​   #!/usr/bin/bash​
      
-  COINFLIP=$((RANDOM % 2))​+  COINFLIP=$((RANDOM % 2))​  # % is the modulus operator
   if [[ "$COINFLIP" == 0 ]]​   if [[ "$COINFLIP" == 0 ]]​
   then​   then​
Line 529: Line 527:
   fi   fi
  
-Note that this script uses extended Unicode characters -- however, for these to display properly, your terminal and terminal font must support the extended characters. Besides emoji, extended characters may be used to display accented characters, symbols, and characters from other languages.+The COINFLIP variable is set to the remainder of the division of ''$RANDOM'' by 2. Therefore, it will have a random value of 0 or 1. 
 + 
 +Note that this script uses extended Unicode characters -- however, for these to display properly, your terminal and your terminal font must both support the extended characters. Besides emoji, extended characters may be used to display accented characters, symbols, and characters from other languages.
  
 === Cautious File Delete === === Cautious File Delete ===
ops102/bash_scripting.1709847380.txt.gz · Last modified: 2024/04/16 18:10 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki