pulling a column from a file in ksh

I would like to pull a column from a file and place it in a variable:

The file would look like this:

N.Korea gibberish garbage
S.Korea gibberish garbage
USA gibberish garbage
Iraq gibberish garbage
Canada gibberish garbage

and items in the first column would be one word only. I would like to place the whole column in a variable. I think sed would be good for this, but I'm not sure of the syntax.
Thanks

How about:

x=$(cut -d ' ' -f 1 < file)

The file was actually tab-delimited so I ended up using this:

x=$(cut -f1 < file)

which achieved the results I was looking for. Thanks!

x=$(cut -d ' ' -f 1 < file)

What shell is syntax from? Is this a form of command grouping used in csh?

or

If this is Korn Shell, why dont you have to use back quotes ( ` ) to execute the commands inside the parens? Are there limitations to this sort of syntax?

This is not csh syntax, it is ksh syntax. Note that the title of this thread explicitly mentions ksh. In ksh, the $(command) is preferred, while the `command` syntax is currently supported for backward compatibility.

The advantage is nesting:
gcos=$(grep $(whoami) /etc/passwd | cut -d: -f5)
is easy to code and easy to read. Depending on the contents of the gcos field:
eval gcos=\`grep `whoami` /etc/passwd \| cut -d: -f5 \'
may or may not work.

Well, here's where it gets tricky:

It turns out that I do need to use the second column. The file would now look like this:

N.Korea NUCLEAR garbage
S.Korea NON-NUCLEAR garbage
USA NUCLEAR garbage
Iraq UNKNOWN garbage
Canada HORSEBACK garbage

(By the way, the second column is a joke, for those who don't get my sense of humor)

But what I need to do is pull out the second column and place it in a separate variable, but in a way that I can still associate it with the first column.

How about:

y=$(cut -f 2 < file)

I wanted to be able to still associate column 1 with column 2, so what I ended up doing was:

I though that needed entire columns in those variables. You can get individual fields with:

exec < file.txt
while read x y junk ; do
     commands
done