Skip to main content
Became Hot Network Question
deleted 26 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 238

Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time.

function time_seconds()
{
  echo "Counting to $1 seconds"
  time_func $1
}

function time_minutes()
{
  echo "Counting to $1 minutes"
  time_func $1*60
}

function time_hours()
{
  echo "Counting to $1 hours"
  time_func $1*60*60
}

function time_flexible()  # accepts flexible input hh:mm:ss (does not work)
{
    echo "Counting to $1"
    secs=$(time2seconds $1)
    time_func $secs
}

enter image description here

I would like to convert all these functions, commands into one function, one command. I think a lot of people would find this almost as useful as the sleep command... well, not quite... but still very convenient to have. Speaking of the sleep command, it works as follows, example:

sleep 5h 22m 44s

I would like to turn these commands into a one stopwatch command in which accepts a input values exactly like the sleep command, example:

stopwatch 5h 22m 44s

Can someone teach/show me how IHow would I go about accomplishing this?

p.s. feel free to modify the stopwatch display output if you see your changes making this more universally accepted as simpler and easier.

Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time.

function time_seconds()
{
  echo "Counting to $1 seconds"
  time_func $1
}

function time_minutes()
{
  echo "Counting to $1 minutes"
  time_func $1*60
}

function time_hours()
{
  echo "Counting to $1 hours"
  time_func $1*60*60
}

function time_flexible()  # accepts flexible input hh:mm:ss (does not work)
{
    echo "Counting to $1"
    secs=$(time2seconds $1)
    time_func $secs
}

enter image description here

I would like to convert all these functions, commands into one function, one command. I think a lot of people would find this almost as useful as the sleep command... well, not quite... but still very convenient to have. Speaking of the sleep command, it works as follows, example:

sleep 5h 22m 44s

I would like to turn these commands into a one stopwatch command in which accepts a input values exactly like the sleep command, example:

stopwatch 5h 22m 44s

Can someone teach/show me how I would go about accomplishing this?

p.s. feel free to modify the stopwatch display output if you see your changes making this more universally accepted as simpler and easier.

Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time.

function time_seconds()
{
  echo "Counting to $1 seconds"
  time_func $1
}

function time_minutes()
{
  echo "Counting to $1 minutes"
  time_func $1*60
}

function time_hours()
{
  echo "Counting to $1 hours"
  time_func $1*60*60
}

function time_flexible()  # accepts flexible input hh:mm:ss (does not work)
{
    echo "Counting to $1"
    secs=$(time2seconds $1)
    time_func $secs
}

enter image description here

I would like to convert all these functions, commands into one function, one command. I think a lot of people would find this almost as useful as the sleep command... well, not quite... but still very convenient to have. Speaking of the sleep command, it works as follows, example:

sleep 5h 22m 44s

I would like to turn these commands into a one stopwatch command in which accepts a input values exactly like the sleep command, example:

stopwatch 5h 22m 44s

How would I go about accomplishing this?

p.s. feel free to modify the stopwatch display output if you see your changes making this more universally accepted as simpler and easier.

typo
Source Link
Anonymous
  • 533
  • 9
  • 16

Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time.

function time_seconds()
{
  echo "Counting to $1 seconds"
  time_func $1
}

function time_minutes()
{
  echo "Counting to $1 minutes"
  time_func $1*60
}

function time_hours()
{
  echo "Counting to $1 hours"
  time_func $1*60*60
}

function time_flexible()  # accepts flexible input hh:mm:ss but doesn't seem(does tonot work)
{
    echo "Counting to $1"
    secs=$(time2seconds $1)
    time_func $secs
}

enter image description here

I would like to convert all these functions, commands into one function, one command. I think a lot of people would find this almost as useful as the sleep command... well, not quite... but still very convenient to have. Speaking of the sleep command, it works as follows, example:

sleep 5h 22m 44s

I would like to turn these commands into a one stopwatch command in which accepts a input values exactly like the sleep command, example:

stopwatch 5h 22m 44s

Can someone teach/show me how I would go about accomplishing this?

p.s. feel free to modify the stopwatch display output if you see your changes making this more universally accepted as simpler and easier.

Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time.

function time_seconds()
{
  echo "Counting to $1 seconds"
  time_func $1
}

function time_minutes()
{
  echo "Counting to $1 minutes"
  time_func $1*60
}

function time_hours()
{
  echo "Counting to $1 hours"
  time_func $1*60*60
}

function time_flexible()  # accepts flexible input hh:mm:ss but doesn't seem to work
{
    echo "Counting to $1"
    secs=$(time2seconds $1)
    time_func $secs
}

enter image description here

I would like to convert all these functions, commands into one function, one command. I think a lot of people would find this almost as useful as the sleep command... well, not quite... but still very convenient to have. Speaking of the sleep command, it works as follows, example:

sleep 5h 22m 44s

I would like to turn these commands into a one stopwatch command in which accepts a input values exactly like the sleep command, example:

stopwatch 5h 22m 44s

Can someone teach/show me how I would go about accomplishing this?

p.s. feel free to modify the stopwatch display output if you see your changes making this more universally accepted as simpler and easier.

Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time.

function time_seconds()
{
  echo "Counting to $1 seconds"
  time_func $1
}

function time_minutes()
{
  echo "Counting to $1 minutes"
  time_func $1*60
}

function time_hours()
{
  echo "Counting to $1 hours"
  time_func $1*60*60
}

function time_flexible()  # accepts flexible input hh:mm:ss (does not work)
{
    echo "Counting to $1"
    secs=$(time2seconds $1)
    time_func $secs
}

enter image description here

I would like to convert all these functions, commands into one function, one command. I think a lot of people would find this almost as useful as the sleep command... well, not quite... but still very convenient to have. Speaking of the sleep command, it works as follows, example:

sleep 5h 22m 44s

I would like to turn these commands into a one stopwatch command in which accepts a input values exactly like the sleep command, example:

stopwatch 5h 22m 44s

Can someone teach/show me how I would go about accomplishing this?

p.s. feel free to modify the stopwatch display output if you see your changes making this more universally accepted as simpler and easier.

Source Link
Anonymous
  • 533
  • 9
  • 16

How to modify these bash functions into one?

Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time.

function time_seconds()
{
  echo "Counting to $1 seconds"
  time_func $1
}

function time_minutes()
{
  echo "Counting to $1 minutes"
  time_func $1*60
}

function time_hours()
{
  echo "Counting to $1 hours"
  time_func $1*60*60
}

function time_flexible()  # accepts flexible input hh:mm:ss but doesn't seem to work
{
    echo "Counting to $1"
    secs=$(time2seconds $1)
    time_func $secs
}

enter image description here

I would like to convert all these functions, commands into one function, one command. I think a lot of people would find this almost as useful as the sleep command... well, not quite... but still very convenient to have. Speaking of the sleep command, it works as follows, example:

sleep 5h 22m 44s

I would like to turn these commands into a one stopwatch command in which accepts a input values exactly like the sleep command, example:

stopwatch 5h 22m 44s

Can someone teach/show me how I would go about accomplishing this?

p.s. feel free to modify the stopwatch display output if you see your changes making this more universally accepted as simpler and easier.