Sponsored Content
Full Discussion: Case inside While read File
Top Forums UNIX for Beginners Questions & Answers Case inside While read File Post 303008130 by Scott on Monday 27th of November 2017 02:55:42 PM
Old 11-27-2017
Your second read is reading from the same descriptor as the first, meaning both reads are reading your input file, meaning that your case will never get the answer you are looking for and the inner while-loop will never break (you can test that by adding a line to your input file with only an n in it, at which point the script will exit).

You need to change one of the reads to read from a different descriptor. There's a number of ways to do this. One way, for example, is to change your second read to:
Code:
read -r -p "Do you wish to continue?[y/n]" yn < /dev/tty

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

case command inside awk/nawk

well I found lot of topics about awk..about if command in awk.. but I had to implement this: nawk -F"|" ' $47 ~ /0R0011/ { print > ("/home/user/M/MC.tmp" )} $47 ~ /0R0012/ { print > ("/home/user/M/DuSI.tmp" )} $47 ~ /0R0014/ { print > ("/home/user/M/FF.tmp" )} $47 ~ /0R0018/ { print >... (9 Replies)
Discussion started by: abdulaziz
9 Replies

2. Shell Programming and Scripting

Case inside case?

Im new to unix and shell scripting. I am required to write a program and im in the process of creating a menu system. I have my main menu but i want to be able to select an option that takes me onto another menu. I have tried doing this with the case statement with no luck so far. Wondering if it... (3 Replies)
Discussion started by: RAFC_99
3 Replies

3. UNIX for Advanced & Expert Users

how to grep/read a file inside compressed tgz without extract?

Hi all, I would like to ask whether in Unix shell/perl have any functions or command to allow grep/cat/read a file inside compressed .tgz without extract it? I know we can tar tvf a compressed tgz but this only allow we read the path/filename contained inside the tarball. If we want to read... (3 Replies)
Discussion started by: mayshy
3 Replies

4. Shell Programming and Scripting

multiple lines inside a case statement

echo "please enter ur choice.. 1. Make a file. 2. Display contents 3. Copy the file 4. Rename the file 5. Delete the file 6. Exit" read choice case $choice in 1 ) echo enter the file name read fname if then echo... (2 Replies)
Discussion started by: gotam
2 Replies

5. UNIX for Advanced & Expert Users

how to read a file inside jar

how to read the text file inside the jar without extracting jar. (3 Replies)
Discussion started by: karthikn
3 Replies

6. Shell Programming and Scripting

Call function inside CASE

i have a case statement which branches to different sections based on an input. Each branch needs to call a function. below is the code. FOr some reason, the code inside the function is not getting executed. the code is below for reference. in the below code echo "Function 1" which is there... (2 Replies)
Discussion started by: cvsanthosh
2 Replies

7. Shell Programming and Scripting

Nested case inside awk

please let me know if the below code could be written efficiently inside single awk case "$INP" in ksh) cat catalog | awk 'BEGIN {FS=",";} { print $2 } END {}' ;; pset) cat catalog | awk 'BEGIN {FS=",";} { print $3 } END {}' ;; dml) cat catalog | awk 'BEGIN {FS=",";} {... (2 Replies)
Discussion started by: cvsanthosh
2 Replies

8. Homework & Coursework Questions

How to read user keyboard input inside the case?

I need to Write a shell script that allows some system-administration tasks to be preformed automatically from a menu-driven interface. with automated following tasks: Copy directory tree Delete files or directories Output Information (this part is done ) *Copy directory tree The “Copy... (2 Replies)
Discussion started by: femchi
2 Replies

9. Shell Programming and Scripting

Update file record inside read loop

Hi, I am reading file records inside a while loop, and want to update the record when certain condition is met. How can I update a file while being read? I want to avoid using temporary files, copy, rename, ... while IFS=',' read -r f1 f2 do function(f1,f2) if then <add... (1 Reply)
Discussion started by: ysrini
1 Replies

10. Shell Programming and Scripting

Use sqlplus statement inside case sentence

Hello, I have a problem. I want to launch a different sql queries for different shell parameter values, something like this. #/bin/bash case $1 in "A") sqlplus -s user/pass << SQL query A; SQL "B") sqlplus -s user/pass << SQL2 ... (3 Replies)
Discussion started by: Vares
3 Replies
io_canread(3)						     Library Functions Manual						     io_canread(3)

NAME
io_canread - return a file descriptor that can be read from SYNTAX
#include <io.h> int64 io_canread(); DESCRIPTION
io_canread returns the next file descriptor that can be read from. You have to have used io_wantread() on the file descriptor earlier, and you have to have called io_wait() or io_waituntil(). These functions then keep an internal data structure on which descriptors were reported readable by the operating system. Please note that there is no guarantee that there still is data that can be read from the descriptor, just that there was data when io_wait() or io_waituntil() were called. Another process could have read the data before you. Look at the result from io_tryread(). If there are no more descriptors that you can write to without blocking, io_canwrite will return -1. In this case you should call io_wait() or io_waituntil() again. You should use io_tryread(3) to read from the descriptor, not plain read(2). If you use read(2) and you get EAGAIN, call io_eagain(3). SEE ALSO
io_wait(3), io_canwrite(3), io_eagain(3) io_canread(3)
All times are GMT -4. The time now is 12:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy