[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] how to understand the xargs

From: lina
Subject: Re: [Help-bash] how to understand the xargs
Date: Tue, 27 Dec 2011 23:50:41 +0800
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20111114 Icedove/3.1.16

On Tuesday 27,December,2011 11:40 PM, Greg Wooledge wrote:
On Tue, Dec 27, 2011 at 11:35:22PM +0800, lina wrote:
On Tuesday 27,December,2011 11:31 PM, Greg Wooledge wrote:
On Tuesday 27,December,2011 11:16 PM, Greg Wooledge wrote:
On Tue, Dec 27, 2011 at 11:27:35PM +0800, lina wrote:
$(...) is command substitution.
$((...)) is arithmetic substitution.
This is a core part,

well, why not it showed me nothing,

after run it?
Command substitution means you run the thing inside $(...) as a command,
and then use its output.

   $ i=3
   $ echo $(i+1)
   bash: i+1: command not found


In this case, it tries to run i+1 as a command (which generates an error).
Then it takes the standard output of that command, word splits it, and
passes the results to echo.  Since the i+1 command did not produce any
standard output (it only produced errors), echo receives no arguments,
so it writes a blank line.

Arithmetic substitution is COMPLETELY different:

   $ i=3
   $ echo $((i+1))

i=$((i+1)) is how you add 1 to the variable named i in /bin/sh.  There
are other ways in bash, but i=$((i+1)) will work in both sh *and* bash,
so you should learn that one first.
Cool. explaination. sometimes my mind really lack the sensitivity towards those things.
But I understand now.

Thanks for your reply,

Best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]