How to loop read command and print valid invalid states.?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to loop read command and print valid invalid states.?
# 1  
Old 12-22-2014
How to loop read command and print valid invalid states.?

My question is how would i loop a read command to keep asking the user for input and eventually print the no. of valid invalid inputs after a specified control input typed i.e. (-3).

Last edited by Flowoftruth; 12-22-2014 at 03:37 PM.. Reason: Original code altered
# 2  
Old 12-22-2014
Please show us what you have tried so far.

Why look for a specific string to terminate input? Why not just use End-Of-File (ctl-d for interactive input)?

Is this a homework assignment?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use while loop to read file and use ${file} for both filename input into awk and as string to print

I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix. I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice. Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

2. Programming

Invalid Read access

Hi All, I would like to know how the valgrind find the runtime allocation related issues?such as the below invalid read of size 4. Invalid write of size 4. Even the size of memory is known at runtime,valgrind reports this I am asking this since i got an issue which is trying to access... (0 Replies)
Discussion started by: SA_Palani
0 Replies

3. Shell Programming and Scripting

Ps command showing different states for same process

I am using HP-UX,KSH $ jobs -l + 19377 Running nohup ksh cat_Duplicate_Records_Removal.ksh </dev/null >/dev/null 2>&1 & $ ps -p 19377 -fl F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME COMD 401 S catmgr 19377 19491 ... (1 Reply)
Discussion started by: TomG
1 Replies

4. Shell Programming and Scripting

For loop inside awk to read and print contents of files

Hello, I have a set of files Xfile0001 - Xfile0021, and the content of this files (one at a time) needs to be printed between some line (lines start with word "Generated") that I am extracting from another file called file7.txt and all the output goes into output.txt. First I tried creating a for... (5 Replies)
Discussion started by: jaldo0805
5 Replies

5. Shell Programming and Scripting

Valid and invalid date in the file

Hi All, How to validate the 4th column,it is date column in the file, if it valid move to valid file else moved invalid file. 9f680174-cb87|20077337254|0|20120511|N 9f680174-cb88|20077337254|0|20120534|N i want two file valid.txt and invalid.txt Thanks, (7 Replies)
Discussion started by: bmk
7 Replies

6. Shell Programming and Scripting

A test command parameter is not valid

Hello, Getting error "A test command parameter is not valid" when trying to run the code below under /sbin/sh AA = "12:00" CHK=$(date +"%H:%M") if then print "Yes" fi Getting 2 errors: 1) "AA: not found" 2) "Specify a parameter with this command" Thanks, IS Please... (5 Replies)
Discussion started by: schureki
5 Replies

7. Shell Programming and Scripting

Whether a string is a valid unix command

How to find a string which is entered in command promt is a valid unix command or not?. Thanks in advance ~Saravana (2 Replies)
Discussion started by: tsaravanan
2 Replies

8. Shell Programming and Scripting

read command (input) inside the while loop

Hi, 'read' command is not working inside the while loop, How can I solve this? Rgds, Sharif. (2 Replies)
Discussion started by: sharif
2 Replies

9. UNIX Desktop Questions & Answers

trying to create a script to read a flie and loop a command...

I tried to explain this earlier, but did a poor job of it. So I am trying again but taking a different approach..... I have a file called test_words. In this file I have one line with 5 three letter words, with a single space seperating the words.(I.e., "cat car mop red pin") I want to... (5 Replies)
Discussion started by: Italy87
5 Replies

10. UNIX for Advanced & Expert Users

trying to create a script to read a flie and loop a command...

Tried to explain this earlier, but did a poor job of it. So I am trying again but taking a different approach..... I have a file called test_words. In this file I have one line with 5 three letter words, with a single space seperating the words.(I.e., "dog car mop red pin") I want to create a... (1 Reply)
Discussion started by: Italy87
1 Replies
Login or Register to Ask a Question