How do i get columns out of text in shell

Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

How do i get columns out of text in shell

Post by mister_v »

Hello,

How do i get columns out of text in shell?

Tried with substrings

Code: Select all

${stringZ:7} 
But it isn't exactly what I'm looking for.
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: How do i get columns out of text in shell

Post by chris »

Hi,

you can do this with awk

For example:

Code: Select all

awk '{ print $2 }' list.txt
This gets the second column from the file list.txt
Standard the separation is space (" ")
With -F you can change this

Code: Select all

awk -F ";" '{ print $2 }' list.txt
You can also use gawk as an alternative.
Post Reply