| | 329 | |
| | 330 | === Pipe ( | ) === |
| | 331 | |
| | 332 | The pipe command, '''|''', takes the output of one command and passes it to another. For example we could "pipe" the output of '''cat''' to '''grep''' in order to search a file for a particular string |
| | 333 | |
| | 334 | {{{ |
| | 335 | [tulaneID@cypress1 examples]$ cat numbers.txt | grep 1 |
| | 336 | 01 |
| | 337 | 10 |
| | 338 | [tulaneID@cypress1 examples]$ |
| | 339 | }}} |
| | 340 | |
| | 341 | === history === |
| | 342 | Displays the command history list with line numbers. You can add an optional integer, n, argument to display only the last n commands |
| | 343 | |
| | 344 | {{{ |
| | 345 | [tulaneID@cypress1 examples]$ history 2 |
| | 346 | 299 cat numbers.txt | grep 1 |
| | 347 | 300 history 2 |
| | 348 | [tulaneID@cypress1 examples]$ |
| | 349 | }}} |
| | 350 | |
| | 351 | Note: '''history''', '''|''', and '''grep''' when used together are a powerful combination as they allow you to search for old commands that you may not remember the exact syntax for: |
| | 352 | |
| | 353 | {{{ |
| | 354 | [tulaneID@cypress1 examples]$ history | grep chmod |
| | 355 | 153 chmod u+x myscript.sh |
| | 356 | 204 chmod +x myexecutable.sh |
| | 357 | 271 chmod +x myscript.sh |
| | 358 | 273 chmod -x myscript.sh |
| | 359 | 301 history | grep chmod |
| | 360 | [tulaneID@cypress1 examples]$ |
| | 361 | }}} |
| | 362 | |