[Ilugc] One Day One Command

  • From: sbharathi@xxxxxxxxxxxxx (Bharathi S)
  • Date: Tue Jan 11 10:04:01 2005

On Mon, 10 Jan 2005, Bharathi S wrote:

On Mon, 10 Jan 2005, Suraj wrote:
Bharathi S wrote: 
| $ echo -n `cat nums` -- Print the file content with-out new line char.
|   1 2 3

Technically, its the shell that interprets the `cat nums` first
and then supplies them to echo as arguments.  It doesn't matter if
we supplied the -n argument here or not.

Thanks for the correction. The '-n' option don't add the new line
char at the end of the output string.

Yday, I gone thru bash manual to get more info abt the command
substitution.

<snip>
Command substitution allows the output of a command to replace the
command itself.  Command substitution occurs when a command is
enclosed as follows:

     $(COMMAND) or `COMMAND`

Bash performs the expansion by executing COMMAND and replacing the
command substitution with the standard output of the command, with any
trailing newlines deleted.  Embedded newlines are not deleted, but
they may be removed during word splitting.  The command substitution
`$(cat FILE)' can be replaced by the equivalent but faster `$(<
FILE)'.

</snip>

Bye :)
-- 
Bharathi S

Other related posts: