DevOps Day 4 - My Bashful Adventure with File Handling & Redirection

Jayanth BJayanth B
2 min read

Today marks Day 4 of my 100-day DevOps journey, and it was all about Bash—especially file handling and redirection.

Why File Handling Matters

File handling is a foundational skill for anyone using the command line. Before advanced tools can make a difference, it's important to understand how to work with files and control the way your commands interact with them.

What I Explored

Input/Output Redirection:

  • > overwrites a file with new output.

  • >> appends new output to the end of a file.

  • < takes input from a file.

  • | pipes output from one command into another.

  • tee saves a copy of the output to a file while still displaying it on the screen.

File Viewing Tools:

  • cat: Displays the entire file.

  • more and less: Scroll through content, useful for longer files.

  • head: Shows the top few lines.

  • tail: Shows the last few lines.

What I Practiced

  • Used echo and redirection to create and update files:

      bashecho "Hello DevOps!" > greeting.txt
      echo "Today is Day 4 of my journey." >> greeting.txt
      cat greeting.txt
    
  • Ran:

      bashls -l | tee file_list.txt
    

    This command both displayed the file list and saved it—a very practical trick.

Reflections

Today, I realized that the Linux shell is more than a tool; it's a way of communicating with your computer. Learning to manage files and redirect outputs is empowering and gives a new level of control.

Now, I can:

  • Create and manage logs easily.

  • View file content quickly.

  • Redirect and manage command output for better automation.

Key Takeaways

  • > and >> help control how outputs are saved.

  • tee is useful for viewing and storing command outputs at the same time.

  • Mastering redirection opens up possibilities for automation and efficiency.

By the end of Day 4, I had created and managed several files, tried new commands, and built a stronger connection with my system. The journey continues!

#100DaysOfDevOps

#DevOpsDiary

#LinuxCommands

#BashMagic

#FromNoobToNinja

0
Subscribe to my newsletter

Read articles from Jayanth B directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Jayanth B
Jayanth B