New answers tagged

1 vote

printing prime number in bash

Arithmetic evaluation in bash uses $(( ... )) so your test would need to be if [[ $((($a-1) % 2)) -eq 0 ]]; then ... but variable expansion is implicit in an arithmetic context, so you could write ...
  • 76.2k
0 votes

Date, arithmetic, and ternary operator in one line

A simple alternative is to just run sleep in in the background and then wait for it after running the other code. #!/bin/bash sleep 500 & # script is here wait

Top 50 recent answers are included