Open Will513r opened 11 months ago
The >
>>
are used for saving information to files that are created or need to be created.
An |
is a way to focus on the information you need. It was explained to me it's like an magnifying glass.
I wouldn't really say |
is like a magnifying glass, it's more like a conveyor belt; moving the outputs of the previous operation into the next.
cat package.json | grep "thing_to_search"
This will print the contents of package.json
to stdout, but instead of actually printing it to stdout, it will send the response into grep
which will search over the results.
Summary
Learn how to redirect input and output in the shell using the
>
,>>,
and|
operators. Mastering these techniques allows you to manipulate how data flows between commands, files, and other I/O streams.Description
Objective: Get a firm grasp on the input/output redirection concept in the command line and become proficient in using
>,``>>,
and|
for various tasks.Scope:
>
for overwriting>>
for appending|
for pipingLearning Tasks
Understanding I/O Redirection:
How to Use
>
for Overwriting:>
operator to redirect output from a command to a file, overwriting the file if it already exists.How to Use
>>
for Appending:>>
operator to append output from a command to an existing file.How to Use
|
for Piping:|
) operator to send the output of one command as the input to another.Hands-on Practice:
>
operator to redirect the output ofls
to a file, thereby saving the listing of a directory to that file.>>
operator to append the output of anotherls
command to the same file.|
operator to pipe the output ofls
intogrep
to filter the results.Troubleshooting:
Learning Goals
>
,>>
, and|
to manipulate I/O streams.Priority