
Bash can be a daunting place for sure, oftentimes you are looking at an unreadable wall of text or you’re pulling your hair our (if you still have any, you egghead) trying to find a file.
This blog post will give you some basic tips that I use to traverse this nightmareish hellscape so that you may hopefully begin to like it like I do.
#1: column command
Below is the video that served as inspiration for this section, but if you’re in a pinch I will outline the commands you can use and add my own usecase.
TLDR : gimme the command
cat /etc/passwd | column -t -s ":"
Explanation
So often times when you are looking at something in bash, you are greeted with the most unfriendly wall of text you can think of. This a neat little feature of Bash and this is just how Linus Torvalds like to prank newbies.
One way to avoid looking at this unstructured mess is to append the column commang at the end of your command. Let me show you what I mean.
Let’s say that you want to see the contents of the /etc/passwd file(if you know you know).
You will be presented with this hard to distinguish mess:

This is really not very readable. So what can we do to make our experience a bit more bearable? Well, enter the system command.
cat /etc/passwd | column -t -s ":"
Here’s how it will look as a result:

Now this looks a lot more managable, here is the explanation:
Command | Explanation |
---|---|
cat | bash command for concatenation |
| (pipe) | this command allows you to use output from one operation as an input for another |
column | this is the command that takes our messy input and displays it in a structured format |
-t | this flag tells the column command that we with to display the output in a table format |
-s [SEPARATOR] | this flag tells the column command that we wish to use a seperator (as this is a csv file) and we specify which seperator we wish to use |
Usecases
This command really shines at formatting predictable text, so something like a CSV file which can easily be split on the “:” separator. There are many cases of this, such as /etc/passwd or /etc/shadow (if you’re a hacker). Here is how this would look like in code
cat file.csv | column -s, -t
You could also apply this to terminal utlities such as ps aux
and df -h
. Here is how this would look like in code
ps aux | column -t
df -h | column -t