Skip to main content
edited body
Source Link

I have a bash time keyword command which I cannot fully explain, but it works for me.

My Goal:

  1. to find the execution time of some python script, which takes a variable btw, from within a bash script, and capture that value.

  2. also to capture the output of the python script in the same variable, for success or failure analysis.

After reading around I ended up with this command, but I am not fully able to explain it.

ttime=$( (TIMEFORMAT="%U^"; time  /../myscript.py ${__myvar} 2>&1 )|& tr -d f)

Can you explain why I need the second command tr -d f in the pipe, for the time value to be appended to the output of the command,

The choice of 'tr -d f' was entirely arbitrary, and will not affect my script's output, std or err, but without it, or another command which acts on the scripts text output in some minor way, I see the return from the python without the time appended, why?

Edit:

The real question should have been why is the |& tr -d f . needed, and as Stephanie says it idis the |& which is allowing the timings found in the sterr from the time keyword to be passed into the pipeline output

Solution now looks like:

ttime=$(TIMEFORMAT="%U^"; { time /../myscript.py ${__myvar} ; } 2>&1 )

Field Descriptor Tutorial:

http://wiki.bash-hackers.org/howto/redirection_tutorial

I have a bash time keyword command which I cannot fully explain, but it works for me.

My Goal:

  1. to find the execution time of some python script, which takes a variable btw, from within a bash script, and capture that value.

  2. also to capture the output of the python script in the same variable, for success or failure analysis.

After reading around I ended up with this command, but I am not fully able to explain it.

ttime=$( (TIMEFORMAT="%U^"; time  /../myscript.py ${__myvar} 2>&1 )|& tr -d f)

Can you explain why I need the second command tr -d f in the pipe, for the time value to be appended to the output of the command,

The choice of 'tr -d f' was entirely arbitrary, and will not affect my script's output, std or err, but without it, or another command which acts on the scripts text output in some minor way, I see the return from the python without the time appended, why?

Edit:

The real question should have been why is the |& tr -d f . needed, and as Stephanie says it id the |& which is allowing the timings found in the sterr from the time keyword to be passed into the pipeline output

Solution now looks like:

ttime=$(TIMEFORMAT="%U^"; { time /../myscript.py ${__myvar} ; } 2>&1 )

Field Descriptor Tutorial:

http://wiki.bash-hackers.org/howto/redirection_tutorial

I have a bash time keyword command which I cannot fully explain, but it works for me.

My Goal:

  1. to find the execution time of some python script, which takes a variable btw, from within a bash script, and capture that value.

  2. also to capture the output of the python script in the same variable, for success or failure analysis.

After reading around I ended up with this command, but I am not fully able to explain it.

ttime=$( (TIMEFORMAT="%U^"; time  /../myscript.py ${__myvar} 2>&1 )|& tr -d f)

Can you explain why I need the second command tr -d f in the pipe, for the time value to be appended to the output of the command,

The choice of 'tr -d f' was entirely arbitrary, and will not affect my script's output, std or err, but without it, or another command which acts on the scripts text output in some minor way, I see the return from the python without the time appended, why?

Edit:

The real question should have been why is the |& tr -d f . needed, and as Stephanie says it is the |& which is allowing the timings found in the sterr from the time keyword to be passed into the pipeline output

Solution now looks like:

ttime=$(TIMEFORMAT="%U^"; { time /../myscript.py ${__myvar} ; } 2>&1 )

Field Descriptor Tutorial:

http://wiki.bash-hackers.org/howto/redirection_tutorial

added 89 characters in body
Source Link

I have a bash time keyword command which I cannot fully explain, but it works for me.

My Goal:

  1. to find the execution time of some python script, which takes a variable btw, from within a bash script, and capture that value.

  2. also to capture the output of the python script in the same variable, for success or failure analysis.

After reading around I ended up with this command, but I am not fully able to explain it.

ttime=$( (TIMEFORMAT="%U^"; time  /../myscript.py ${__myvar} 2>&1 )|& tr -d f)

Can you explain why I need the second command tr -d f in the pipe, for the time value to be appended to the output of the command,

The choice of 'tr -d f' was entirely arbitrary, and will not affect my script's output, std or err, but without it, or another command which acts on the scripts text output in some minor way, I see the return from the python without the time appended, why?

Edit:

The real question should have been why is the |& tr -d f . needed, and as Stephanie says it id the |& which is allowing the timings found in the sterr from the time keyword to be passed into the pipeline output

Solution now looks like:

ttime=$(TIMEFORMAT="%U^"; { time /../myscript.py ${__myvar} ; } 2>&1 )

Field Descriptor Tutorial:

http://wiki.bash-hackers.org/howto/redirection_tutorial

I have a bash time keyword command which I cannot fully explain, but it works for me.

My Goal:

  1. to find the execution time of some python script, which takes a variable btw, from within a bash script, and capture that value.

  2. also to capture the output of the python script in the same variable, for success or failure analysis.

After reading around I ended up with this command, but I am not fully able to explain it.

ttime=$( (TIMEFORMAT="%U^"; time  /../myscript.py ${__myvar} 2>&1 )|& tr -d f)

Can you explain why I need the second command tr -d f in the pipe, for the time value to be appended to the output of the command,

The choice of 'tr -d f' was entirely arbitrary, and will not affect my script's output, std or err, but without it, or another command which acts on the scripts text output in some minor way, I see the return from the python without the time appended, why?

Edit:

The real question should have been why is the |& tr -d f . needed, and as Stephanie says it id the |& which is allowing the timings found in the sterr from the time keyword to be passed into the pipeline output

Solution now looks like:

ttime=$(TIMEFORMAT="%U^"; { time /../myscript.py ${__myvar} ; } 2>&1 )

I have a bash time keyword command which I cannot fully explain, but it works for me.

My Goal:

  1. to find the execution time of some python script, which takes a variable btw, from within a bash script, and capture that value.

  2. also to capture the output of the python script in the same variable, for success or failure analysis.

After reading around I ended up with this command, but I am not fully able to explain it.

ttime=$( (TIMEFORMAT="%U^"; time  /../myscript.py ${__myvar} 2>&1 )|& tr -d f)

Can you explain why I need the second command tr -d f in the pipe, for the time value to be appended to the output of the command,

The choice of 'tr -d f' was entirely arbitrary, and will not affect my script's output, std or err, but without it, or another command which acts on the scripts text output in some minor way, I see the return from the python without the time appended, why?

Edit:

The real question should have been why is the |& tr -d f . needed, and as Stephanie says it id the |& which is allowing the timings found in the sterr from the time keyword to be passed into the pipeline output

Solution now looks like:

ttime=$(TIMEFORMAT="%U^"; { time /../myscript.py ${__myvar} ; } 2>&1 )

Field Descriptor Tutorial:

http://wiki.bash-hackers.org/howto/redirection_tutorial

added 106 characters in body
Source Link

I have a bash time keyword command which I cannot fully explain, but it works for me.

My Goal:

  1. to find the execution time of some python script, which takes a variable btw, from within a bash script, and capture that value.

  2. also to capture the output of the python script in the same variable, for success or failure analysis.

After reading around I ended up with this command, but I am not fully able to explain it.

ttime=$( (TIMEFORMAT="%U^"; time  /../myscript.py ${__myvar} 2>&1 )|& tr -d f)

Can you explain why I need the second command tr -d f in the pipe, for the time value to be appended to the output of the command,

The choice of 'tr -d f' was entirely arbitrary, and will not affect my script's output, std or err, but without it, or another command which acts on the scripts text output in some minor way, I see the return from the python without the time appended, why?

Edit:

The real question should have been why is the |& tr -d f . needed, and as Stephanie says it id the |& which is allowing the timings found in the sterr from the time keyword to be passed into the pipeline output

Solution now looks like:

ttime=$(TIMEFORMAT="%U^"; { time /../myscript.py ${__myvar} ; } 2>&1 )

I have a bash time keyword command which I cannot fully explain, but it works for me.

My Goal:

  1. to find the execution time of some python script, which takes a variable btw, from within a bash script, and capture that value.

  2. also to capture the output of the python script in the same variable, for success or failure analysis.

After reading around I ended up with this command, but I am not fully able to explain it.

ttime=$( (TIMEFORMAT="%U^"; time  /../myscript.py ${__myvar} 2>&1 )|& tr -d f)

Can you explain why I need the second command tr -d f in the pipe, for the time value to be appended to the output of the command,

The choice of 'tr -d f' was entirely arbitrary, and will not affect my script's output, std or err, but without it, or another command which acts on the scripts text output in some minor way, I see the return from the python without the time appended, why?

Edit:

The real question should have been why is the |& tr -d f . needed, and as Stephanie says it id the |& which is allowing the timings found in the sterr from the time keyword to be passed into the pipeline output

I have a bash time keyword command which I cannot fully explain, but it works for me.

My Goal:

  1. to find the execution time of some python script, which takes a variable btw, from within a bash script, and capture that value.

  2. also to capture the output of the python script in the same variable, for success or failure analysis.

After reading around I ended up with this command, but I am not fully able to explain it.

ttime=$( (TIMEFORMAT="%U^"; time  /../myscript.py ${__myvar} 2>&1 )|& tr -d f)

Can you explain why I need the second command tr -d f in the pipe, for the time value to be appended to the output of the command,

The choice of 'tr -d f' was entirely arbitrary, and will not affect my script's output, std or err, but without it, or another command which acts on the scripts text output in some minor way, I see the return from the python without the time appended, why?

Edit:

The real question should have been why is the |& tr -d f . needed, and as Stephanie says it id the |& which is allowing the timings found in the sterr from the time keyword to be passed into the pipeline output

Solution now looks like:

ttime=$(TIMEFORMAT="%U^"; { time /../myscript.py ${__myvar} ; } 2>&1 )

added 224 characters in body
Source Link
Loading
noted that its a keyword and swapped refs to builtin
Source Link
Loading
added 28 characters in body
Source Link
Loading
edited body
Source Link
Loading
Source Link
Loading