Quick Links
You’ve learned how to create scripts, use arguments, and build for loops.
The command-line is wonderful for many reasons, and redirection is one of the most prominent.
Redirection lets us use that output and save it or immediately use it as an input for another command.
We can also use files as inputs for other commands.
This is done by using a backslash () in front of the character.
It’s a better idea to use quotes.
The echo command also works with variables.
As you’ve got the option to see, single and double quotes behave differently.
For more information, check outWhat’s the Difference Between Single and Double Quotes in the Bash Shell?
cat– This command displays the contents of text files as output.
grep – This is one of the most powerful and useful commands available to you in Linux.
It stands for Global/Regular Expression Print.
It looks through a file and prints any line that matches a particular pattern.
For not, though, it’s possible for you to enter a tern for searching.
Let’s change our list up, shall we?
Also take note that the previous contents of “list” were removed.
For this, we use two consecutive greater-than symbols:
echo yellow peppers » list
Easy!
Let’s use this command to create a larger list, shall we?
Essentially, it takes the output of one command and directly feeds it to another.
As it’s possible for you to see, grep is case-sensitive.
you’ve got the option to use the “-i” flag to make it ignore case.
cat < list
“That’s not any different from using an argument!”
Well, you’d be correct in this case.
Where redirection of input really comes in handy is in chaining commands together.
grep pep < list > revisions
Let’s redo this command, and add some sorting.
And, anything that is valid in quotes can be substituted for your first argument!
As far as sorting goes, it’s possible for you to do more than just sort alphabetically.