Testa om variabel är satt: Difference between revisions

From Linuxwiki
Jump to navigation Jump to search
Linuxwiki>Wikiadmin
Skapade sidan med '== Testa om variabel är satt i Bash == Källa: http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/scripts/node5.html Exempel verify if the PRINTER environment variable is...'
 
m 2 revisions imported
 
(One intermediate revision by one other user not shown)
Line 14: Line 14:
  ''' echo "$PRINTER is set"'''
  ''' echo "$PRINTER is set"'''
  '''fi'''
  '''fi'''
[[Kategori:bash]]

Latest revision as of 21:53, 11 May 2026

Testa om variabel är satt i Bash

Källa: http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/scripts/node5.html

Exempel

verify if the PRINTER environment variable is set

$ cat ~/tools/exsh/isset.sh

#!/bin/bash
#
if test "${PRINTER+set}" != set ; then
 echo "$PRINTER is not set"
else
 echo "$PRINTER is set"
fi

Kategori:bash