Page 1 of 1

How do i get columns out of text in shell

Posted: Mon Aug 30, 2010 11:13 pm
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.

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

Posted: Tue Aug 31, 2010 2:07 pm
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.