12-02-2008
issues with a condition in a while loop
Hi,
I am facing issues with test condition. I had a compound condition to write for both if and while,
In one of the texts i referred, with a korn shell we can write compound statements like: [[condition1 || condition 2 ]], however this doesn't worked for me. For example:
if [[ "$go_2_it" == "Y" || "$go_2_it" == "y" ]] doesn't works, but
if [ "$go_2_it" = "Y" ] || [ "$go_2_it" = "y" ] worked.
Now, similarly in a while loop I have something like,
while [[ "$go_2_it" != "Y" || "$go_2_it"t != "y" || "$go_2_it" != "N" || "$go_2_it" != "n" ]] or
while [ "$go_2_it" != "Y" ] || [ "$go_2_it" != "y" ] || [ "$go_2_it" != "N" ] || [ "$go_2_it" != "n" ]
None of the above works, do not understand why.
Also, if anybody can suggest whats [[ ]], and does it behaves differently than []. In the text, I referred, it says [[]] is for korn and [] is for bash. I am working with korn shell, but [[]] doesn't help me.
Thanks
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi guys,
Been sifting through these forums for awhile, but never had an account or needed to post. Shoutouts to a great forum with heaps of useful info.
Now i consider myself a noob when it comes to linux and to bash scripting. I recently started to learn to use Vmware ESX server which uses... (4 Replies)
Discussion started by: ryath
4 Replies
2. UNIX for Dummies Questions & Answers
i have got a file where the env command is appended 5 times. i have to now look for the username and display it in the form of
1) PWD=/home/lee.ballancore
2) USER=lee.ballancore
3) MAIL=/var/spool/mail/lee.ballancore
4) LOGNAME=lee.ballancore
5) HOME=/home/lee.ballancore
6)... (1 Reply)
Discussion started by: nehaquick
1 Replies
3. UNIX for Dummies Questions & Answers
How do I test the return condition in the script if no files are found:
for file in `Find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN}`
do
...
..
done
I want to capture the return code so I can echo the error or condition. Using if ] always returns zero no matter where it's placed.
... (4 Replies)
Discussion started by: mavsman
4 Replies
4. Shell Programming and Scripting
I have a for loop in my script as shown below.
for file_path in $file_list ; do
........my code
..........
......
done
Can i restrict the number of files parsing to the variable file_path as 50?
That is, even if I have some 100 files in file_list, I need to take only 50 files for... (7 Replies)
Discussion started by: Vijay06
7 Replies
5. Programming
Hi,
I have written a program in C and have to test the return value of the functions. So the normal way of doin this wud b
int rc
rc=myfunction(input);
if(rc=TRUE){
}
else{
}
But instead of doing this I have called the function in the if() condition. Does this have any... (2 Replies)
Discussion started by: sidmania
2 Replies
6. Shell Programming and Scripting
Gurus,
I need to read a line from a file and strip the characters from it and compare the stripped value with the value I pass to the script while executing it. Below is the code for the same. But when i execute the code, it is throwing an error.
#!/bin/ksh
. /home/.i_env
... (14 Replies)
Discussion started by: svajhala
14 Replies
7. Shell Programming and Scripting
Hi,
Could you please tell what is the meaning of -z in while loop condition.
For example,
while ; do
echo "*** Enter the age "
readage (3 Replies)
Discussion started by: vidyaj
3 Replies
8. UNIX for Advanced & Expert Users
All,
I wrote the following section of code (which logically in PHP would of worked):
tmpPATH=${1}
tmpTAG=${2}
if
then
while read tmpTAG tmpPATH
do
fi
echo $tmpTAG
echo $tmpPATH
if
then
done < ./config.cfg
fi (4 Replies)
Discussion started by: Cranie
4 Replies
9. Shell Programming and Scripting
Hi,
I was trying to write a shell script which reads csv file and sends mail in html format along with tables. Hope i have completed 1st part , but while sending mail i was trying to highlight some rows in the table based on the egrep outcome. If the string exists in line/INPUT, i am trying to... (4 Replies)
Discussion started by: varmas424
4 Replies
LEARN ABOUT REDHAT
xmcvtxmstringtoct
XmCvtXmStringToCT(library call) XmCvtXmStringToCT(library call)
NAME
XmCvtXmStringToCT -- A compound string function that converts a compound string to compound text
SYNOPSIS
#include <Xm/Xm.h>
char * XmCvtXmStringToCT(
XmString string);
DESCRIPTION
XmCvtXmStringToCT converts a compound string to a (char *) string in compound text format. The application must call XtAppInitialize
before calling this function. The converter uses the font list tag associated with a given compound string segment to select a compound
text format for that segment. A registry defines a mapping between font list tags and compound text encoding formats. The converter uses
the following algorithm for each compound string segment:
1. If the compound string segment tag is mapped to XmFONTLIST_DEFAULT_TAG in the registry, the converter passes the text of the compound
string segment to XmbTextListToTextProperty with an encoding style of XCompoundTextStyle and uses the resulting compound text for
that segment.
2. If the compound string segment tag is mapped to an MIT registered charset in the registry, the converter creates the compound text
for that segment using the charset (from the registry) and the text of the compound string segment as defined in the X Consortium
Standard Compound Text Encoding.
3. If the compound string segment tag is mapped to a charset in the registry that is neither XmFONTLIST_DEFAULT_TAG nor an MIT regis-
tered charset, the converter creates the compound text for that segment using the charset (from the registry) and the text of the
compound string segment as an "extended segment" with a variable number of octets per character.
4. If the compound string segment tag is not mapped in the registry, the result is implementation dependent.
string Specifies a compound string to be converted to compound text.
RETURN
Returns a (char *) string in compound text format. This format is described in the X Consortium Standard Compound Text Encoding. The
function allocates space to hold the returned string. The application is responsible for managing the allocated space. The application
can recover the allocated space by calling XtFree.
RELATED
XmCvtCTToXmString(3), XmFontList(3), XmMapSegmentEncoding(3), XmRegisterSegmentEncoding(3), and XmString.
XmCvtXmStringToCT(library call)