![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to transform a string to a variable? | Kerstin | Shell Programming and Scripting | 3 | 12-19-2007 08:46 AM |
| How to check a string in the variable | josephwong | Shell Programming and Scripting | 1 | 06-25-2006 09:14 PM |
| problems egreging for a '(0)' string | m223464 | Shell Programming and Scripting | 9 | 02-03-2006 09:51 AM |
| find: problems escaping printf-command string | grahamb | Shell Programming and Scripting | 1 | 12-04-2005 01:00 PM |
| how to cut a string from a variable | kjaisan | UNIX for Dummies Questions & Answers | 2 | 10-30-2003 10:13 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
variable= 'cat file|wc -l' String problems
Hi,
does anybody knows about wc -l, how to transform it inot a just number? this script ALWAYS executes the command3!!, However, the value of BMU_RUNNING is 1 case $BMU_RUNNING in *0) command1 ;; *1) command 2;; *)command 3;; esac The variable is BMU_RUNNING=`more channels.dat|grep BMU |grep RUNNING|wc -l` and it is equal to 1 echo $BMU_RUNNING is 1 but with set -x + + more channels.dat + grep BMU + grep RUNNING + wc -l BMU_RUNNING= 1 thanks for your help Santiago |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Can you try this
Code:
grep -c BMU_RUNNING channels.dat Code:
grep |wc -l Here's a test script: Code:
#!/bin/sh BMU_RUNNING=`grep -c BMU_RUNNING channels.dat` case "$BMU_RUNNING" in *0) echo it is "* zero";; *1) echo it is "* one";; *) echo it is "*";; esac Code:
ASDJS DBMU BMU_RUNNING AKLJFIDF ASJDKSJD Last edited by blowtorch; 07-08-2005 at 07:36 AM. Reason: now tested |
|
#3
|
|||
|
|||
|
Try to Get rid of the * in front of the 0 and 1 and see if that works.
|
|
#4
|
|||
|
|||
|
thanks blowtorch
that worked, I just modifiyes as my chnnels.dat file is something like: CHANNEL(TO.BMUUZA1) STATUS(STOPPED) CHANNEL(TO.YMQ2) STATUS(RUNNING) CHANNEL(TO.BMUUZA1) STATUS(RUNNING) CHANNEL(TO.YMQ1) STATUS(RUNNING) to BMU_RUNNING=`grep BMU channels.dat|grep -c RUNNING` case $BMU_RUNNING in *0) echo `date`" WARNING, No Mainframe Channels TO.BMUAA1 are running " echo " Please, start the channels or contact Mainframe transaction sy stems team" ;; *1) echo `date`" One Mainframe Channels TO.BMUAA1 not running " echo " Please, start the channel or contact Mainframe transaction sys tems team" ;; *);; esac Thanks again so much Santiago |
|||
| Google The UNIX and Linux Forums |