Redirects Flashcards
How can you add text to a file or overwrite an existing file?
echo “text” > /path/to/file
How can you append text to an existing file?
echo “text”»_space; /path/to/file
What are the 3 standard redirects in Linux?
stdin (0) stdout (1) stderr (2)
What is the input redirect symbol?
<
Give an example of the input redirect action
wc < testfile (sending the testfile into the word count program - same as cat testfile | wc)
How can you suppress error output from a command?
<command></command>
2> /dev/null
Give an example of the tee command
echo “TESTING” | tee testfile (saves to file and displays “TESTING” on stdout - overwrites existing)
How can you append to file using tee?
echo “TESTING” | tee -a testfile
What is the | (pipe) used for?
To send the output of one command to the input of another command
How do you redirect output and error to the same place?
2>&1
What location can you redirect to to discard output?
/dev/null