[Top][All Lists]

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

Re: [Help-bash] counter for executed commands in non interactive mode?

From: Chet Ramey
Subject: Re: [Help-bash] counter for executed commands in non interactive mode?
Date: Mon, 18 May 2015 13:49:39 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 5/18/15 11:57 AM, Meike Stone wrote:
>>> is there a easy way, to count inside a bash script the executed
>>> (external) commands while this script itself is executed?
>>> Normaly, the commands are counted in the interactive mode and
>>> displayed in the command prompt if "\#" is configured.
>>> Maybe, there is a possibility to access this counter?
>> The shell attempts to count the number of commands executed, but it's
>> not limited to external executed commands: it includes both compound
>> and simple commands, including builtins and shell functions.  The \#
>> prompt expansion is the only place where that count is exposed.
> ... but it is not possible to access this internal counter?

Correct.  The only place that count is exposed is the \# prompt expansion.
We can talk about extensions to expose it in other ways (e.g., some new
variable), but it's only an approximation and not guaranteed to be the
right value for everyone.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden

reply via email to

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