New answers tagged numeric-data
1
vote
Test for a number in bash
Depends what you mean by number. 0x12, inf, 1.2, -12, ¹²³, ⑱, 1e6, 1,000,000, Ⅷ, 0x123p-5, 6,23, 0b100110 are all numbers by some definitions of number, and 08, 019, ...
- 497k
1
vote
Accepted
Test for a number in bash
It is not, as a simple test will show us:
#!/bin/bash
for var in 1 2 3 a b c; do
if [[ "$var" =~ '^[[:digit:]]+$' ]]; then
echo "$var is a number"
else
echo "$var ...
- 29.3k
Top 50 recent answers are included
Related Tags
numeric-data × 240text-processing × 88
awk × 84
shell-script × 37
linux × 27
bash × 26
sed × 25
grep × 20
sort × 20
shell × 13
command-line × 12
scripting × 12
regular-expression × 11
text-formatting × 8
test × 8
arithmetic × 8
printf × 7
floating-point × 7
columns × 6
bc × 6
variable × 5
csv × 5
random × 5
perl × 4
file-comparison × 4