Archive
Posts Tagged ‘column’
Cut a column in bash
March 20, 2011
Leave a comment
Problem
You have a line of text and you want to extract a given column.
Solution
Use awk for instance. Indexing starts with 1. Example:
C:~> date
Sun Mar 20 12:16:17 EDT 2011
C:~> date | awk '{print $2}'
Mar
C:~>
Of course, we could have written “date '+%b'” in this case, but I wanted to show how to cut a column.
Categories: bash
awk, column, cut, cut column