08-23-2002
Quote:
Originally posted by Perderabo
for my infinite loops. Unix systems also have a "true" and "false" command. So
while true ; do
is another reasonable way to do infinite loops.
I believe that the while true; do is the best way to approach infinite loops when needed. Simple and straightforward and similiar to other programming languages.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
hello....very new user to unix...and i have a question..i am not sure if there is such a thing
For example...the user is asked if he likes Bananas....if he says yes....
echo You like Bananas $name
at the end of the script it echos all that the user has entered so they can read it....
but... (1 Reply)
Discussion started by: jonas27
1 Replies
2. Shell Programming and Scripting
I am running on HPUX using ksh.
I have a script that uses a loop within a loop, for some reason the script seems to hang on a particuliar record. The record is fine and hits the condition in Blue. If I kill the 1st loop process the script continues on with no problem.
Begin code>
<Some... (8 Replies)
Discussion started by: bthomas
8 Replies
3. UNIX for Dummies Questions & Answers
I'm trying to create a loop that will prompt the user for 15 values, not forcing them to enter all 15. If the user enters through one or more of the prompts the null value needs to be converted to 0, otherwise set the parameter = to the value entered:
ex.
Please enter file no #1: 17920
... (4 Replies)
Discussion started by: vdc
4 Replies
4. UNIX for Dummies Questions & Answers
Hi,
how can I use "for" to have two loops :
this is my script :
for i in (A B C)
do
for j in (a b c)
do
echo $i$j
done
done
#End
I want to print out
Aa
Ab
Ac ....
But I have error message :
syntax error at line 1 : `(' unexpected
Many thanks before.
How should I use "for" ?? (2 Replies)
Discussion started by: big123456
2 Replies
5. Shell Programming and Scripting
Hi
I've a file like so:
Now, I want to read my file and take ex. the Media ID and the Type for each groups of Media (Media1,Media2,...,Media(n):
cat /tmp/file|\
while read FILE
do
while $(FILE|cut -d: -f1)=Media$i
do
#here will be some test, ex:
#if Media ID < 23
... (4 Replies)
Discussion started by: nymus7
4 Replies
6. UNIX for Dummies Questions & Answers
I am traversing down a list, and I am not quite sure how to tell the loop to break when it's done going through the file.
#!/bin/sh
while :
do
read list <&3
echo $list
done
is the code. The file "list" is simply
5
4
3
2
1
any advice on how to break the loop after the file is... (1 Reply)
Discussion started by: MaestroRage
1 Replies
7. Shell Programming and Scripting
#!/bin/bash
IFS=$'\n'
A= a c b t g j i e d
B= t y u i o p
counter=0
found=""
for i in $(cat $A)
do
for j in $(cat $B)
do
if
then
found="yes"
fi
done
if
then (1 Reply)
Discussion started by: vadharah
1 Replies
8. Shell Programming and Scripting
Hi All,
I want to execute a script the number of times a user enters. Please can you advise on hor can I do the same.
Many Thanks,
Shazin (4 Replies)
Discussion started by: Shazin
4 Replies
9. UNIX for Dummies Questions & Answers
Hello,
I'm not sure if this is more appropriate for the 'unix for dummies' or the 'unix for experts' forum because I'm new to this forum and this is the second topic I've discussed, but if you could let me know which one was more appropriate for something like this, please do!
So in tr (an... (2 Replies)
Discussion started by: juliette salexa
2 Replies
10. UNIX for Dummies Questions & Answers
Why wont my for statements work? Im trying to get this script to swich to a user an if you put in a start/stop/or restart paramater to do just that for each user. I commented out the actual start/stop actions to test it just by using echos and not do anything hasty in the environment but it... (0 Replies)
Discussion started by: LilyClaro
0 Replies
TEST(1) General Commands Manual TEST(1)
NAME
test, [ - test for a condition
SYNOPSIS
test expr
[ expr ]
OPTIONS
(none)
EXAMPLES
test -r file # See if file is readable
DESCRIPTION
Test checks to see if files exist, are readable, etc. and returns an exit status of zero if true and nonzero if false. The legal operators
are
-r file true if the file is readable
-w file true if the file is writable
-x file true if the file is executable
-f file true if the file is not a directory
-d file true if the file is a directory
-s file true if the file exists and has a size > 0
-t fd true if file descriptor fd (default 1) is a terminal
-z s true if the string s has zero length
-n s true if the string s has nonzero length
s1 = s2 true if the strings s1 and s2 are identical
s1 != s2 true if the strings s1 and s2 are different
m -eq m true if the integers m and n are numerically equal
The operators -gt, -ge, -ne, -le, and -lt may be used as well. These operands may be combined with -a (Boolean and), -o (Boolean or), !
(negation). The priority of -a is higher than that of -o. Parentheses are permitted, but must be escaped to keep the shell from trying to
interpret them.
SEE ALSO
expr(1), sh(1).
TEST(1)