Difference between revisions of "OPS435 Lecture 3 - Bash"

From CDOT Wiki
Jump to: navigation, search
(Created page with 'Linux processes * ps * kill * top Using BASH History * history command * ! command Shell Expansions * Pathname expansion examples ** ls abc* ** echo abc? ** LANG=C;echo [A-Z]*…')
 
m (Andrew moved page OPS435 Lecture 3 to OPS435 Lecture 3 - Bash)
 
(3 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
* history command
 
* history command
 
* ! command
 
* ! command
 +
 +
User-define variables
 +
* Setting
 +
* Reading
 +
 +
Quoting & escaping
 +
* Single quotes
 +
* Double quotes
 +
* Back quotes
 +
* Escaping special characters
  
 
Shell Expansions
 
Shell Expansions
Line 15: Line 25:
 
** LANG=C;echo [A-Z]*
 
** LANG=C;echo [A-Z]*
 
* brace expansion examples
 
* brace expansion examples
** seq command
 
 
** echo {1..5}
 
** echo {1..5}
 
** echo {a..m}
 
** echo {a..m}
Line 32: Line 41:
 
** echo $((2 + 2))
 
** echo $((2 + 2))
 
** x=$((5/2))
 
** x=$((5/2))
 
* Parameter expansion examples
 
** echo $1
 
** echo ${11}
 
 
Input from the user
 
* read command
 

Latest revision as of 13:40, 22 August 2017

Linux processes

  • ps
  • kill
  • top

Using BASH History

  • history command
  •  ! command

User-define variables

  • Setting
  • Reading

Quoting & escaping

  • Single quotes
  • Double quotes
  • Back quotes
  • Escaping special characters

Shell Expansions

  • Pathname expansion examples
    • ls abc*
    • echo abc?
    • LANG=C;echo [A-Z]*
  • brace expansion examples
    • echo {1..5}
    • echo {a..m}
    • touch file{1,2,3,4}
    • touch file{1..4}
    • touch file{2,4,6,8}
    • mkdir ops435/{labs,notes}
  • Tilde expansion examples
    • echo ~
  • Command substitution examples
    • echo $(date)
    • echo `date`
  • Arithmetic expansion examples
    • echo $((2 + 2))
    • x=$((5/2))