urgent help in counting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting urgent help in counting
# 1  
Old 05-20-2008
urgent help in counting

Hi,

When i am running the following shell scripting then i am getting the following output..

echo "sunita"
echo "now date is: `date`"
echo "enter command"
read command
read command
read command
read command
echo "command is: $command"
if [ "$command" = "" ]
then
echo "command is blank"
else
count=1
echo "count is $count"
((count=$count++1))
echo "it is enterred only $count times"
fi


Output is:
sunita
now date is: tuesday 20 40:9
count is 1
it is enterred only 2 times ---> here i need the 4 times(because i have entered 4 times in $command)

Can anybody tell me that how shell i get it??????
It is very urgent.....
can anybody help me???????
# 2  
Old 05-20-2008
Hammer & Screwdriver Your program is linear, not a loop

You read input four times. Each time, storing to the same variable name.
Then, you check on its status.
Print a 1 as count variable
add 1 to count
print out count again
Thus, the program is executing exactly as you wrote it.

You want to:
--store each variable to a distinct name
--loop through the variables when done (not a one-time if)
# 3  
Old 05-20-2008
I got it but can you please tell me with the example...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

2. Shell Programming and Scripting

Counting a Char

how to count how many R in the below file. Rttt 1Rxxx GG 2R 3R 4R 5R 6R 7R R0 R1 R2 R3 R4 R5 R6 R7 RR (10 Replies)
Discussion started by: theshashi
10 Replies

3. UNIX for Dummies Questions & Answers

counting?

Hi all, I promise this is my very last dumb question.. but how to you count how many unique names you have. My dataset is: >Bac1 afdsgrr >Bac4 egege >Bac8 dgrjh >Bac1 afdsgrr >Bac1 afdsgrr >Bac8 dgrjh What i want to know is that how many unique names there is, so the output would... (3 Replies)
Discussion started by: Iifa
3 Replies

4. Shell Programming and Scripting

Counting

Hi, The following output shows how many pmon process are started by users named : oracle or yoavb $ ps -ef |grep pmon |grep -v grep |grep -v ipmon oracle 11268 1 0 Sep 2 ? 36:00 ora_pmon_qerp oracle 17496 1 0 Oct 11 ? 8:58 ora_pmon_bcv oracle 15081 1 0 ... (5 Replies)
Discussion started by: yoavbe
5 Replies

5. Shell Programming and Scripting

counting characters

Hi All, I need some help in counting the number of letters in a big file with separations. Following is the file I have >AB_1 MLKKPIIIGVTGGSGGGKTSVSRAILDSFPNARIAMIQHDSYYKDQSHMSFEERVKTNYDHPLAFDTDFM IQQLKELLAGRPVDIPIYDYKKHTRSNTTFRQDPQDVIIVEGILVLEDERLRDLMDIKLFVDTDDDIRII... (6 Replies)
Discussion started by: Lucky Ali
6 Replies

6. UNIX for Dummies Questions & Answers

counting words

if i have a long list of data, with every line beginning with an ip-address, like this: 62.165.8.187 - - "GET /bestandnaam.html HTTP/1.1" 200 5848 "http://www.domeinnaam.nl/bestandnaam.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" how do i count which ip-adresses are mentioned... (3 Replies)
Discussion started by: FOBoy
3 Replies

7. Shell Programming and Scripting

Counting

Hi, I want to count how many rows are in a file for a specific column. eg. K NM K NM K NM K JK K NM K JK K NM so the file is tab-delimited. I want to count how many rows are in column 2 and how many NMs there are. I used awk awk '{OFS="\t"}; {count++} {print i,... (3 Replies)
Discussion started by: phil_heath
3 Replies

8. Shell Programming and Scripting

Counting Processes

I have a simple script that I want to notify me whenever there are anything other than one instance of a particular process running. I've always used the script: DPID_DW=$(ps -ef | grep | wc -l) if then echo "The data warehouse manager for DB is down" elif then ... (4 Replies)
Discussion started by: heprox
4 Replies

9. UNIX for Advanced & Expert Users

URGENT,URGENT- Need help tape drive installation

Hi, I am trying to attach tape drive to sun V890 running Solaris 9 on it. I have installed HBA(qlogic) in slot 1 of 0-8 slots and booted the system. I do not see HBAin prtdiag output. The tape drive is not attached to HBA. The tape drive I am going to attach is Sony AIT3. 1.How can I make... (3 Replies)
Discussion started by: sriny
3 Replies
Login or Register to Ask a Question