Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

How can I cut second column from the following list from terminal?

56    267  
57    235  
58    255  
59    283 
share|improve this question

4 Answers 4

up vote 3 down vote accepted

If the data is in a file called test.txt, awk '{ print $1 }' test.txt will do it.

share|improve this answer
This is for first column. – Radu Rădeanu Oct 23 '13 at 7:51
You'll want awk '{ print $2 }' file.txt instead, to get the 2nd column. – minerz029 Oct 23 '13 at 9:33
Yes. I know that. But the way I read the question I thought OP wanted to retain the first column. – user25656 Oct 23 '13 at 9:50

If the space between columns is a Tab character, then

cut -f 2

will do what you want. If they are spaces, then compress them to a single tab first:

tr -s \  \\t | cut -f 2
share|improve this answer

Try with:

sed -e "s/[[:space:]]\+/\t/g" filename | cut -f2

First command (sed) will replace all whitespace characters with one tab, and the result will be passed to the second command (cut) which will select the second field from each line.

See man cut and man sed for more info.

share|improve this answer

If your data was separated with a column then your operation will be a lot easier .

kmcet@ubuntu:~$ cat data.txt
kmcet@ubuntu:~$ cut -d, -f1,1  data.txt

so there main part is -f1,1 so its keeping the data only from field 1 to again 1.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.