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
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.
(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.