Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file (called text) that contains two fields of strings (separated by space) like what follows:

1.2.3  version1

When I use set command as follows, I have the first field in the $1 and the second field in $2. Can someone explain what this command does? In particular what < does? Is this an input redirection?

set -- $(<text)
share|improve this question
up vote 3 down vote accepted

That command combines two rather special tricks...

set --

Usually set is used to configure shell options (see the man page of your shell). A special case is set --. This is used to set the positional parameters. Unfortunately I have forgotten what that was about but I once read about a problem which could not be solved well by other means.

$(< file)

$(command) is command subsitution: The shell collects the output on stdout and replaces $(command) by that output when executing the command line. If you need the content of a file you could do this: $(cat file). $(< file) is just a short version of that, saving an unnecessary process (cat).

share|improve this answer
Just to clarify: set 1.2.3 version1 would also set $1 to 1.2.3 and $2 to version1. The -- tells set to stop accepting flags. That way, if the file text contained something along the lines of -k version1, set would not confuse the first field of the file's text for a flag. – Evan Teitelman Jun 4 '13 at 20:47
@EvanTeitelman, set -- tells set to stop accepting flags and to stop outputting all the variables when not passed any argument. – Stéphane Chazelas Jun 4 '13 at 20:51

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.