How to view file content after redirection?

QuestionsQuestions8 SkillsProDec, 18 2025
098

After you use redirection (> or >>) to send content into a file, you won't see any output on the terminal immediately because the output was "redirected" into the file instead of your screen.

To view the content and verify it worked, you simply use the cat command (or other viewing commands) on the file you just created or modified.

Example Walkthrough:

  1. Perform the redirection:

    cat /tmp/hello > my_new_file

    (The terminal stays silent because the text went into my_new_file)

  2. View the result:

    cat my_new_file

Other ways to view the content:

If you want to use different tools depending on the file size or your needs:

  • less my_new_file: Best for longer files. It lets you scroll up and down using your arrow keys. Press q to quit and return to the prompt.
  • head -n 5 my_new_file: If you just want to see the first 5 lines to make sure the redirection started correctly.
  • tail -n 5 my_new_file: If you used >> (append) and want to check if the new data was successfully added to the very bottom.

Try it now:
If you just ran a command like cat /tmp/hello > together, type cat together to see the results of your work!

0 Comments

no data
Be the first to share your comment!