Unix Commands

Unix Commands

Explains how to understand complex unix commands. Covers pipes, stdin, stdout, stderr, xargs, etc.

Bca7defe7b8087d8e261d32b29cf425e?s=128

Joshua Paling

March 15, 2018
Tweet

Transcript

  1. JOSS @joshuapaling

  2. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  3. ✂ --

  4. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  5. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  6. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  7. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | <AND FOR THOSE FILES AS %…> ‘ <FORMAT THEM WITH PRETTIER> ; <STAGE THEM FOR THIS COMMIT>'
  8. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  9. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  10. None
  11. 010100010101111001010 101001010010101010100 101001010111101010100

  12. None
  13. The quick brown fox jumped over the lazy dog.

  14. Software dev and “Hello Hungry, I’m Dad” enthusiast. resume.txt

  15. alert(“you have know idea what you’re getting in to”) helloWorld.js

  16. None
  17. None
  18. /dev/null /dev/random /dev/zero

  19. None
  20. None
  21. None
  22. /dev/null /dev/random /dev/zero

  23. The quick brown fox jumped over the lazy dog. /dev/null

    /dev/random /dev/zero
  24. 1. Small, composable ⚒ 2. = Stream of

  25. STDIN STDOUT STDERR

  26. STANDARD INPUT STANDARD OUTPUT STANDARD ERROR

  27. STANDARD INPUT STANDARD OUTPUT STANDARD ERROR

  28. 1. Small, composable ⚒ 2. = Stream of 3. 3

    streams: IN, OUT, ERR
  29. STANDARD INPUT STANDARD OUTPUT STANDARD ERROR

  30. STANDARD INPUT STANDARD OUTPUT STANDARD ERROR /dev/null

  31. STANDARD INPUT STANDARD OUTPUT STANDARD ERROR

  32. STANDARD INPUT STANDARD OUTPUT STANDARD ERROR

  33. None
  34. None
  35. None
  36. None
  37. None
  38. None
  39. None
  40. None
  41. None
  42. None
  43. None
  44. None
  45. None
  46. None
  47. None
  48. None
  49. None
  50. None
  51. None
  52. > anywhere.txt

  53. >> anywhere.txt

  54. 2> anywhere.txt

  55. 2>> anywhere.txt

  56. None
  57. None
  58. None
  59. None
  60. None
  61. None
  62. None
  63. None
  64. None
  65. None
  66. None
  67. None
  68. None
  69. None
  70. None
  71. None
  72. None
  73. None
  74. > anywhere.txt < anywhere.txt

  75. None
  76. None
  77. None
  78. None
  79. None
  80. None
  81. None
  82. None
  83. None
  84. None
  85. None
  86. None
  87. None
  88. None
  89. None
  90. None
  91. None
  92. 1. Small, composable ⚒ 2. = Stream of 3. 3

    streams: IN, OUT, ERR 4. ↔ with <, >, 2>
  93. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  94. None
  95. None
  96. |

  97. | ls -1 grep ‘res’

  98. None
  99. None
  100. None
  101. None
  102. None
  103. None
  104. None
  105. None
  106. None
  107. None
  108. None
  109. None
  110. None
  111. None
  112. None
  113. None
  114. None
  115. None
  116. None
  117. None
  118. None
  119. None
  120. 1. Small, composable ⚒ 2. = Stream of 3. 3

    streams: IN, OUT, ERR 4. ↔ with <, >, 2> 5. | | |
  121. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  122. None
  123. None
  124. None
  125. None
  126. subl stdin XgKkGs.txt

  127. None
  128. None
  129. None
  130. None
  131. None
  132. None
  133. None
  134. None
  135. None
  136. None
  137. None
  138. None
  139. None
  140. None
  141. None
  142. None
  143. None
  144. None
  145. None
  146. None
  147. None
  148. None
  149. None
  150. None
  151. None
  152. None
  153. None
  154. None
  155. None
  156. None
  157. 1. Small, composable ⚒ 2. = Stream of 3. 3

    streams: IN, OUT, ERR 4. ↔ with <, >, 2> 5. | | | 6. xargs: STDIN to ARGUMENTS
  158. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  159. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  160. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  161. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  162. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  163. None
  164. None
  165. None
  166. None
  167. README.md client/src/components/nav/Nav.jsx client/src/reducers/consideration.js public/index.js

  168. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  169. <STAGED FILES> | grep -E '.*\\.(js|jsx)$' | grep -v ^public/

    | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  170. <STAGED FILES> | grep -E '.*\\.(js|jsx)$' | grep -v ^public/

    | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  171. <STAGED FILES> | grep -E '.*\\.(js|jsx)$' | grep -v ^public/

    | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  172. <STAGED FILES> | <THAT ARE JS / JSX> | grep

    -v ^public/ | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  173. README.md client/src/components/nav/Nav.jsx client/src/reducers/consideration.js public/index.js

  174. README.md client/src/components/nav/Nav.jsx client/src/reducers/consideration.js public/index.js

  175. client/src/components/nav/Nav.jsx client/src/reducers/consideration.js public/index.js

  176. <STAGED FILES> | <THAT ARE JS / JSX> | grep

    -v ^public/ | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  177. <STAGED FILES> | <THAT ARE JS / JSX> | grep

    -v ^public/ | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  178. client/src/components/nav/Nav.jsx client/src/reducers/consideration.js public/index.js

  179. client/src/components/nav/Nav.jsx client/src/reducers/consideration.js public/index.js

  180. client/src/components/nav/Nav.jsx client/src/reducers/consideration.js public/index.js

  181. client/src/components/nav/Nav.jsx client/src/reducers/consideration.js

  182. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  183. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  184. client/src/components/nav/Nav.jsx client/src/reducers/consideration.js

  185. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  186. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | <AND FOR THOSE FILES AS %…> ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  187. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | <AND FOR THOSE FILES AS %…> ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  188. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | <AND FOR THOSE FILES AS %…> ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  189. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | <AND FOR THOSE FILES AS %…> ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %’
  190. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | <AND FOR THOSE FILES AS %…> ‘ <FORMAT THEM WITH PRETTIER> ; <STAGE THEM FOR THIS COMMIT>'
  191. 1. Small, composable ⚒ 2. = Stream of 3. 3

    streams: IN, OUT, ERR 4. ↔ with <, >, 2> 5. | | | 6. xargs: STDIN to ARGUMENTS
  192. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  193. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c 'prettier --single- quote --trailing-comma es5 --write %; git add %'
  194. git diff --staged --diff- filter=dx --name-only HEAD | grep -E

    '.*\\.(js|jsx)$' | grep -v ^public/ | xargs -I % sh -c ‘ prettier --single-quote -- trailing-comma es5 --write %; git add %'
  195. <STAGED FILES> | <THAT ARE JS / JSX> | <NOT

    IN PUBLIC DIR> | <AND FOR THOSE FILES AS %…> ‘ <FORMAT THEM WITH PRETTIER> ; <STAGE THEM FOR THIS COMMIT>'
  196. ✂ --