Sponsored Content
Top Forums UNIX for Dummies Questions & Answers if...elif...fi condition in Unix Post 27544 by Kelam_Magnus on Tuesday 3rd of September 2002 02:55:46 PM
Old 09-03-2002
In the man page it shows an example. But you are correct that test statement is usually used with another structure.

It is usually used in conjuction with some type of conditional statement like while, for, if, until, etc...



while test -r <myfile> # if the file exists
do
somecommand
done

OR

[ ! -f thisfile ] && echo default > thisfile



My brain is your brain....

Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If and Or Condition in Unix [ksh]

I have the code below. I want to said If TrackErrors > 0 or count == 0 then MailErrors else MailSuccess fi. if then MailErrors ${count} else MailSuccess ${count} fi Any helps greatly appreciated. (2 Replies)
Discussion started by: leemjesse
2 Replies

2. Shell Programming and Scripting

If..elif..else...fi

Hi all, I got some problems on executing the following scripts. Scripts: if ]; then echo "M${str}O 0 1" >> ${tempFile} elif ]; then echo "M${str}O 1 0" >> ${tempFile} else echo "M${str}O 0 0" >> ${tempFile} fi Error: "`;' is not expected." what's the problem? (2 Replies)
Discussion started by: Rock
2 Replies

3. Shell Programming and Scripting

Unix and db2 where condition issue(new line)

Hi I am extracting a column value(DESCRIPTION) from one table and passing it to another db2 statement in a shell code to fetch some value(ID) but the value when passed in where condition is taking as newline+value. Please find the out put when executed: + echo description is ::::... (1 Reply)
Discussion started by: msp2244
1 Replies

4. Shell Programming and Scripting

if condition to check the hostname (unix)

I want to know the if condition in checking the hostname in unix and then running a cron job (all in a single line) Thanks (2 Replies)
Discussion started by: prash358
2 Replies

5. Shell Programming and Scripting

how to use split command in unix shell with a condition

Hi all, I have a file which I want to split into several files based on a condition. This files has several records. I want one record per file. Each record ends with a //. So, I want to separate files based on this condition. I want split files to be named with the name across the field ID (for... (2 Replies)
Discussion started by: kaav06
2 Replies

6. Shell Programming and Scripting

Condition checking in UNIX

i have a script where i have to find the age of a file, if then echo "dnb file is present for the monthly load" >> $RUNLOG dnb="1" else echo "dnb file has not arrived yet" > $ERRLOG dnb="0" fi i know the file is available so... (3 Replies)
Discussion started by: lovelysethii
3 Replies

7. Shell Programming and Scripting

Checking for null condition in a UNIX variable

i have this code for i in `cat sql_output.txt` do -- some script commands done sql_output.txt has 1 column with employee_ids If the sql_output.txt is null then the do loop should not execute. How can i implement this. for i in `cat sql_output.txt` If i is null or empty then ... (5 Replies)
Discussion started by: rafa_fed2
5 Replies

8. Shell Programming and Scripting

If Condition Issue in UNIX

Hi I am trying to do a "IF" Condition in UNIX where we compare EACH file size in a directory with a SIZE (Parameter passed) If Each File size EXCEEDS parameter passed SIZE then we manipulate the file. Somehow the IF condition do not work ?? (is this Variable decalration issue ??) ... (9 Replies)
Discussion started by: Pete.kriya
9 Replies

9. UNIX for Advanced & Expert Users

How to create folder by using if and elif condition?

Hi All, I have already code to create folder for one country let say US , now we want to create folder/directory for JP country also using shell script , application server. $COUNTRY='US' if ] then if mkdir -m 777 -p /opt/TEST/$COUNTRY/$INVOICE >/dev/null 2>&1 | tee -a ... (5 Replies)
Discussion started by: Boost
5 Replies

10. Shell Programming and Scripting

Issue with condition "if then elif else fi"

Hi everybody, I must get trought a shell script 3 arguments. 1st argument = $1 (can take values REP1..4) 2nd argument = $2 (can take values A..Z) 3rd arguement = $3 (also can take values A...Z) I've written this code : #!/bin/bash if then liste=/data/folder1 echo... (6 Replies)
Discussion started by: shellX
6 Replies
THINK(1)						      General Commands Manual							  THINK(1)

NAME
think - you don't have to think, the computer can think for you SYNOPSIS
think [ -detach ] DESCRIPTION
Think simulates a thinking brain. This can be useful if someone is not wanting to think at invocation time or if someone is needing some thinking about something. It can also be helpful if someone's brain is not working correctly at invocation time. When invoked, think will go ahead and look at all of the commands and keystrokes that a user has made during the current login session. Think will then look at what files the user has. From this and what level the user is listed at in the file /usr/lib/think, think will figure out what the user was trying to do when think was invoked. DEVICES
The process that think uses to help a user is greatly aided if the user is wearing a brain interface bus (bib) device. A bib device is normally worn on the head, and if being used, then think will try to see what was going through the users head at the time of invocation. After think does this, it will send electric signals to the users brain, causing the user to type in whatever keystrokes are necessary to accomplish the task that he/she doesn't want to think about. OPTIONS
-detach also known as "Must mother do all of your thinking for you?"-mode. This options causes think to run in the background as a daemon that watches for users who look like they may need assistance. When a user is found to be exercising cluelessness, think will lock up their keyboard and will proceed to execute what seems to be the most likely sequence of commands that the user had intended to execute. This flag may only be used by the super-user. FILES
/dev/brain bib device special file. /usr/lib/think file to indicate various user abilities. The format of this file is a username on each line followed by some whitspace and then a number. The higher the number for a given user, the more likely think is to assume that that user knows what he/she is doing. Unfortunately, what think considers a large number will vary with usage. BUGS
If a user is using a bib device and actually lacks a brain of their own, then there is a high risk that think will take over their (non- existent) minds. This has the upshot that someone other than the user will have to stop the program. (Perhaps this is a feature.) It may illegal in some areas to force users to wear bib devices. AUTHOR
This man page was written by John Guthrie <guthrie@math.upenn.edu> with suggestions from Kevin Whyte <kwhyte@math.upenn.edu> for the alt.sysadmin.recovery man page collection. think version 1.0 April 5, 1996 THINK(1)
All times are GMT -4. The time now is 08:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy