Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare integers on fish shell?

Tags:

fish

There isn't much documentation on fish. I need to know if

    date '+%k' is greater than 8

How do I do it? Thanks.

like image 748
kierkegaard Avatar asked Jan 18 '17 18:01

kierkegaard


Video Answer


2 Answers

You can use the test fish builtin, like:

if test (date +%k) -gt 8
   ...
end
like image 148
Grisha Levit Avatar answered Nov 09 '22 08:11

Grisha Levit


test or [ are the way you would do this. This is true of all shells, since these are external commands.

if [ (date '+%k') -ge 8 ]
    echo "It's larger!"
end
like image 20
ridiculous_fish Avatar answered Nov 09 '22 08:11

ridiculous_fish