Sponsored Content
Top Forums Shell Programming and Scripting Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d Post 302374780 by Max89 on Wednesday 25th of November 2009 12:14:20 PM
Old 11-25-2009
Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code:

Code:
while test 1 -eq 1
do
read a
$a
if test $a = stop
then
  break
fi 
done

I read a command on every loop an execute it.
I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test.
For example echo hello.
Now the script doesn't anything useful,but the idea is to count the frequency of some commands so I want to use test.
Another little issue:
How can I give "infinite" arguments to my script?

Thank you in advance.

EDIT: Ops I printed some script on the title...
 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

string test?

hey guys- what is the syntax for a string test to verify that a user has entered a 6 digit numeric? Thanks for your help in advance! Todd (9 Replies)
Discussion started by: hedrict
9 Replies

2. Solaris

test and .test in same directory

i am using solaris 5.10. i can create two different files "test" and ".test" in the same directory. now suppose i want to change the attribute of the hidden file .test to visible is it possible??? since "." is just an attribute to mark a file hidden why is unix allows creation of "file" and... (14 Replies)
Discussion started by: vikashtulsiyan
14 Replies

3. UNIX for Dummies Questions & Answers

test a string...

Hi! I'm using echo $string | grep "" -c to test in a script if a string is a number and it seems to work. But how can i find, for example, if a string is a four figures number ? Thanks to all! (2 Replies)
Discussion started by: Kaminski
2 Replies

4. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

5. Shell Programming and Scripting

Prefixing test case methods with letter 'test'

Hi, I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
Discussion started by: royalibrahim
5 Replies

6. Shell Programming and Scripting

Shc : trying to test functionality "test" compiling but can not execute

I am testing shc to see if it would help with my need. Im at a point where Im trying to compile and test the "test.ksh" file that comes in the tar ball : shc-3.8.9> shc -v -r -f test.ksh shc shll=ksh shc =-c shc =exec '%s' "$@" shc = shc opts= shc: cc test.ksh.x.c -o test.ksh.x... (7 Replies)
Discussion started by: popeye
7 Replies
while(n)						       Tcl Built-In Commands							  while(n)

__________________________________________________________________________________________________________________________________________________

NAME
while - Execute script repeatedly as long as a condition is met SYNOPSIS
while test body _________________________________________________________________ DESCRIPTION
The while command evaluates test as an expression (in the same way that expr evaluates its argument). The value of the expression must a proper boolean value; if it is a true value then body is executed by passing it to the Tcl interpreter. Once body has been executed then test is evaluated again, and the process repeats until eventually test evaluates to a false boolean value. Continue commands may be exe- cuted inside body to terminate the current iteration of the loop, and break commands may be executed inside body to cause immediate termi- nation of the while command. The while command always returns an empty string. Note: test should almost always be enclosed in braces. If not, variable substitutions will be made before the while command starts execut- ing, which means that variable changes made by the loop body will not be considered in the expression. This is likely to result in an infinite loop. If test is enclosed in braces, variable substitutions are delayed until the expression is evaluated (before each loop iter- ation), so changes in the variables will be visible. For an example, try the following script with and without the braces around $x<10: set x 0 while {$x<10} { puts "x is $x" incr x } SEE ALSO
break(n), continue(n), for(n), foreach(n) KEYWORDS
boolean value, loop, test, while Tcl while(n)
All times are GMT -4. The time now is 08:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy