Skip to main content
Commonmark migration
Source Link

#Bash + GNU utils, 43

Bash + GNU utils, 43

  • Saved 2 bytes thanks to @Dennis
  • Saved 5 bytes thanks to @zeppelin
c=date\ +%s%3N
s=`$c`
seq -1e3 1e3
$c-$s|bc

The date command gives the number of seconds since the epoch concatenated with current nanoseconds. This command is run before and after. bc takes the difference and prints.

Try it online.


I was hoping to do this for 17:

time seq -1e3 1e3

But the output of time gives more than we need:

real    0m0.004s
user    0m0.000s
sys 0m0.004s

#Bash + GNU utils, 43

  • Saved 2 bytes thanks to @Dennis
  • Saved 5 bytes thanks to @zeppelin
c=date\ +%s%3N
s=`$c`
seq -1e3 1e3
$c-$s|bc

The date command gives the number of seconds since the epoch concatenated with current nanoseconds. This command is run before and after. bc takes the difference and prints.

Try it online.


I was hoping to do this for 17:

time seq -1e3 1e3

But the output of time gives more than we need:

real    0m0.004s
user    0m0.000s
sys 0m0.004s

Bash + GNU utils, 43

  • Saved 2 bytes thanks to @Dennis
  • Saved 5 bytes thanks to @zeppelin
c=date\ +%s%3N
s=`$c`
seq -1e3 1e3
$c-$s|bc

The date command gives the number of seconds since the epoch concatenated with current nanoseconds. This command is run before and after. bc takes the difference and prints.

Try it online.


I was hoping to do this for 17:

time seq -1e3 1e3

But the output of time gives more than we need:

real    0m0.004s
user    0m0.000s
sys 0m0.004s
deleted 5 characters in body
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264

#Bash + GNU utils, 4743

  • Saved 2 bytes thanks to @Dennis
  • Saved 5 bytes thanks to @zeppelin
c=date\ +%s%3N
s=`$c`
seq -1e3 1e3
bc<<<`$c`$c-$s$s|bc

The date command gives the number of seconds since the epoch concatenated with current nanoseconds. This command is run before and after. bc takes the difference and prints.

Try it onlineTry it online.


I was hoping to do this for 1917:

time seq -10001e3 10001e3

But the output of time gives more than we need:

real    0m0.004s
user    0m0.000s
sys 0m0.004s

#Bash + GNU utils, 47

  • Saved 2 bytes thanks to @Dennis
  • Saved 5 bytes thanks to @zeppelin
c=date\ +%s%3N
s=`$c`
seq -1e3 1e3
bc<<<`$c`-$s

The date command gives the number of seconds since the epoch concatenated with current nanoseconds. This command is run before and after. bc takes the difference and prints.

Try it online.


I was hoping to do this for 19:

time seq -1000 1000

But the output of time gives more than we need:

real    0m0.004s
user    0m0.000s
sys 0m0.004s

#Bash + GNU utils, 43

  • Saved 2 bytes thanks to @Dennis
  • Saved 5 bytes thanks to @zeppelin
c=date\ +%s%3N
s=`$c`
seq -1e3 1e3
$c-$s|bc

The date command gives the number of seconds since the epoch concatenated with current nanoseconds. This command is run before and after. bc takes the difference and prints.

Try it online.


I was hoping to do this for 17:

time seq -1e3 1e3

But the output of time gives more than we need:

real    0m0.004s
user    0m0.000s
sys 0m0.004s
edited body
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264

#Bash + GNU utils, 5547

  • Saved 2 bytes thanks to @Dennis
  • Saved 5 bytes thanks to @zeppelin
c=date\ +%s%N+%s%3N
s=`$c`
seq -10001e3 10001e3
$c|dc bc<<<`$c`-e?$s-A\ 6^/p

The date command gives the number of seconds since the epoch concatenated with current nanoseconds. This command is run before and after. dcbc takes the difference and divides by A^10 (i.e 1000000) to give the result in millisecondsprints.

Try it onlineTry it online.


I was hoping to do this for 19:

time seq -1000 1000

But the output of time gives more than we need:

real    0m0.004s
user    0m0.000s
sys 0m0.004s

#Bash + GNU utils, 55

c=date\ +%s%N
s=`$c`
seq -1000 1000
$c|dc -e?$s-A\ 6^/p

The date command gives the number of seconds since the epoch concatenated with current nanoseconds. This command is run before and after. dc takes the difference and divides by A^10 (i.e 1000000) to give the result in milliseconds.

Try it online.


I was hoping to do this for 19:

time seq -1000 1000

But the output of time gives more than we need:

real    0m0.004s
user    0m0.000s
sys 0m0.004s

#Bash + GNU utils, 47

  • Saved 2 bytes thanks to @Dennis
  • Saved 5 bytes thanks to @zeppelin
c=date\ +%s%3N
s=`$c`
seq -1e3 1e3
bc<<<`$c`-$s

The date command gives the number of seconds since the epoch concatenated with current nanoseconds. This command is run before and after. bc takes the difference and prints.

Try it online.


I was hoping to do this for 19:

time seq -1000 1000

But the output of time gives more than we need:

real    0m0.004s
user    0m0.000s
sys 0m0.004s
Source Link
Digital Trauma
  • 73k
  • 9
  • 112
  • 264
Loading