How To & Tee Bash

How To Articles

Today, I want to share with you all some of my favorite commands in the Bash shell – “how to” and “tee”. These two commands have been incredibly useful for me in my daily work as a developer. Let’s dive into how we can use these commands effectively and add personal touches along the way.

What is the “how to” Command?

The “how to” command is not a standard Unix/Bash command, but it’s a great trick to know. I often use it when I forget the exact syntax for a specific command. Here’s how it works: simply type “how to” followed by what you want to do, and the command will return relevant examples and usage of related commands. It’s like having a personal Bash cheat sheet at your fingertips.

Example:

Let’s say I want to know how to use the “grep” command. I simply type “how to grep” in my terminal and instantly get a list of usage examples and related commands for grep. It saves me valuable time and keeps my workflow smooth.

Using the “tee” Command

The “tee” command is a simple yet powerful tool in the Unix/Bash environment. It allows me to redirect the output of a command to a file and also simultaneously display it in the terminal. This has been incredibly useful when I want to save the output of a complex command for future reference.

Example:

Let’s say I run a complex command and I want to save the output to a file while also seeing the output in my terminal. I simply add “| tee output.txt” at the end of my command and voila! The output is both displayed on my screen and saved to the “output.txt” file.

Adding Personal Touches

As a developer, I often find myself customizing my Bash environment to streamline my workflow. I’ve created my own aliases and functions to make common tasks easier. For example, I have an alias for “git status” that I’ve named “gs” and a function to quickly create a new directory and change into it with just one command.

Example:

My custom “gs” alias allows me to type “gs” instead of “git status” – saving me a few keystrokes each time. It’s a small customization, but it adds up over time!

Conclusion

In conclusion, mastering these two commands – “how to” and “tee” – has greatly improved my efficiency and productivity as a developer. Whether it’s quickly finding command examples or efficiently managing command output, these tools have become indispensable in my daily work. I encourage you to try them out and explore how they can enhance your own workflow.