LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Blogs > Jukka's script corner
User Name
Password

Notices


Using posix-sh (sh, ksh, bash, ...)

My site (finnish)

My first language is finnish, then
sh, C, awk, K, ... english ...
Sorry about my finglish.
Sh handbook, syntax, FAQ
Old

If - how to use

Posted 12-05-2008 at 02:27 AM by kshfi (Jukka's script corner)
Updated 12-07-2008 at 09:57 AM by kshfi
Tags bash, ksh

Programmers - shell if is command.

Code:
if command exit code is 0
then
    do something 1
    do something 2
fi
Ex.
Code:
if  cp fromfile tofile
then
   echo "Works fine"
else
   echo "Error ???"
fi
[ = test
You can write test or [

Code:
a=1
b=1
test "$a" = "$b"
echo $?
0

a=1
b=2
...
LQ Newbie
Views 1895 Comments 0 kshfi is offline

  



All times are GMT -5. The time now is 04:57 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration