Results 1 to 4 of 4
Is it possible to take only 1 specific column of a big data file and copy it into a new file i made in vi? I'm trying to make a ...
- 06-11-2009 #1Just Joined!
- Join Date
- Jun 2009
- Location
- New York
- Posts
- 12
[SOLVED] Copying 1column of data file to new file?
Is it possible to take only 1 specific column of a big data file and copy it into a new file i made in vi? I'm trying to make a graph but that involves moving that one column of data to a new file, because I don't want to use any other column in the graph.
Thanks
- 06-11-2009 #2Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
Try using awk. Assuming the columns are separated by spaces and let's say you want the 3rd column the command would look like:
If the columns are separated by something other than spaces, let's say commas, then the -F option is needed.Code:awk '{print $3}' filename > newfilename
Code:awk -F',' '{print $3}' filename > newfilename
- 06-12-2009 #3
Or, you could use cut whose sole purpose is to do such things.
The equivalents for the above examples of awk would be:
cut -f 3 < filename > newfilename
cut -d "," -f 3 < filename > newfilename
- 06-15-2009 #4Just Joined!
- Join Date
- Jun 2009
- Location
- New York
- Posts
- 12
Thank you both so much! it worked, and that's relatively simple, I don't know why I could not find that anywhere.


