Teste de Condição comando test Linux

Syntaxe do comando test

test condição && true || false

Teste se arquivo existe

test -e /tmp/a && echo exist || echo not exist

Teste se numero e maior ou menor que 3

test 7 -gt 3  && echo '> que 3' || echo '< que 3'
test 1 -gt 3  && echo '> que 3' || echo '< que 3'

Tabela de condições do comando test

https://documentacoes.wordpress.com/2012/07/18/opcoes-do-comando-test-ou/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s