Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
  • Redirection of output: > vs >>

    • redirect sends a channel of output to a file.

    • A channel refers to standard input/output as well as standard error (not covered here).

    • You can redirect a file as input to a command using < and << (not looked atcovered here).

  • Using pipe “|’

    • A pipe passes standard output as the standard input to another command

  • Examples of the form: 

    • View a text file and pipe to grep.

    • Cat a list and sort by line.

    • Sort and then find unique items.

    • View folder contents and look for a specifically named name.

...

Note

Make sure you are use the commands and options as you intend and understand and be able to describe and explain/justify.

Notice the difference between:

Code Block
[salexan5@mblog1 intro_to_linux]$ cat vegatables.txt | grep beans | sort
...
kidney beans
...
soy beans

and

Code Block
[salexan5@mblog1 intro_to_linux]$ cat vegatables.txt | grep -i beans | sort
...
kidney beans
kidney BEANS
...
soy beans
Soy Beans
  • What happens if you use bean instead of beans?

  • What does the uniq -i option do?

Note

Again: Explore and understand how commands work, and the order they are run in. For example, in your own time, understand if there is a difference between sort | uniq versus uniq | sort?

Expand
titleBrief Explanation:
Info

uniq isn’t able to detect the duplicate lines unless they are adjacent to each other.

That is why we sort first.

Try it and see…

...