Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. February 24th Notes
  2.  
  3. Loops (Can Refer To February 10th Notes)
  4.  
  5. number-based for loop (Regular loop) --> Yay
  6.  
  7. list-based for loop (For each) --> Ugh
  8.  
  9. Number-based For Loop (Refer To myKoolestGameV3.bash)
  10. ----------------------------------------------------
  11.  
  12. for((i=0;i<#;i++));
  13. do
  14. // stuff
  15. done <-- Ends the loop
  16.  
  17. value=$(( <-- Double para's mean a pocket of arithmitic
  18. ^ ^ <-- Dollar sign means that it's going to the value
  19. | <-- Name
  20.  
  21. $ - You can access what's inside the variable (Not like Java)
  22.  
  23. Quotes
  24. ------
  25.  
  26. 1.) " <-- Half-quotes: allow expansions. (Allows groupings of characters)
  27. 2.) ' <-- Full-quotes: literal quote - No expansion (Characters)
  28. 3.) ` <-- Back-quote/tick: enabling command expansion
  29. 4.) $( ) <-- Does the same thing as 3 (Unix prefers this method)
  30.  
  31. Example: echo "$(ls)" <-- You want the quotes to display what's happening.
  32.  
  33. Expansions
  34. ----------
  35. 1.) variable expansion
  36. 2.) algebraic expansion value=$((math))
  37. 3.) command expansion
  38.  
  39. Neat Tricks
  40. -----------
  41.  
  42. ${0} <-- Naming wise, it names it the actual name of the program running it.
  43.  
  44.  
  45.  
  46. List Base For-each Loop
  47. -----------------------
  48.  
  49. for item in $*; <-- Probably refering to the current directory your in.
  50. do
  51.  
  52.  
  53.  
  54. done
  55.  
  56. OR
  57.  
  58. for entry in a b c d; <-- Runs a b c d, number of times
  59. do
  60.  
  61.  
  62.  
  63. done
  64.  
  65. OR
  66.  
  67. for entry in 'ls';
  68. do
  69.  
  70. // This one is really cool
  71.  
  72. done
  73.  
  74.  
  75. Wild Cards
  76. ----------
  77.  
  78. * - 0 or more of anything
  79. ? - 1 of any single character
  80. [ ] - Character class (Grouping of characters. Example: ls [t] --> List everything with a t (Lowercase or Uppercase)
  81. [^ ] - Inverted char class (When grouped with characters, means those characters cannot be that.
  82. ^ <-- [^aeiou]?? First character cannot be those characters.
  83.  
  84. /////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement