Re: simple question



On 2007-06-21, Carbon wrote:
On Wed, 20 Jun 2007 23:38:13 +0000, DanceRat wrote:

What's the difference between $(cat $1) and `cat $1` ?

Quoting is simpler with $() style command substitution. You have to escape
backslashes when using `` syntax. And when nesting commands you have to
escape the inner quotes with backslashes. It can get tricky. I always use
the newer $() form.

Btw you can just do $(< $1) instead of $(cat $1).

Only with some shells (bash, ksh93), yes. It is not standard.

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.



Relevant Pages

  • Re: simple question
    ... Quoting is simpler with $style command substitution. ... escape the inner quotes with backslashes. ... Depends in what you call standard. ...
    (comp.unix.shell)
  • Re: simple question
    ... Quoting is simpler with $style command substitution. ... escape the inner quotes with backslashes. ...
    (comp.unix.shell)
  • Re: pygame music, cant read mp3?
    ... format is to use backslashes as separators, ... escaped in python's regular string literals, ... only because you've been lucky in not having escape characters following ... Notice that the \ gets doubled automatically by python in many ...
    (comp.lang.python)
  • Re: get only filenames and not directory names under a specific path.
    ... > I'm guess maybe it's must do that when it's double quotes. ... but with two exceptions: the escape character itself ... the string delimiter can also be escaped to allow embedded single quotes, ... means that a path with a trailing backslash needs two backslashes there to avoid ...
    (perl.beginners)
  • Re: Reading Text Files
    ... Did not your compiler generate some mandatory diagnostics on ... escape sequences invoking undefined behaviour. ... the OP is not using C99. ... because backslashes are escape characters in ISO C. ...
    (comp.lang.c)