[Ilugc] One Day One Command

  • From: suraj@xxxxxxxxxxx (Suraj)
  • Date: Tue Jan 11 10:34:12 2005

Bharathi S wrote: 
,----
| 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)'.
`----

exactly. The following helps demonstrate:

~ $ cat txt/foo.txt 
the quick brown
 fox jumped
 over the
 lazy dog
~ $ echo $(<txt/foo.txt)
the quick brown fox jumped over the lazy dog
~ $ echo `cat txt/foo.txt`
the quick brown fox jumped over the lazy dog
~ $ echo -n `cat txt/foo.txt `
the quick brown fox jumped over the lazy dog~ $ 

Note, in  the last  command with  'echo -n', how  the prompt  ended up
sticking close to the output. because  echo -n didn't add a newline in
the end.

cheers,

  -Suraj

-- 
,-----------------[http://www.symonds.net/~suraj/]---o
| The first "American" to become popular as a carnatic vocalist was the Late
| John Higgins also called as Higgins Bhaagavathar!
`------------------------------[suraj@xxxxxxxxxxx]---o

Other related posts: