Sponsored Content
Full Discussion: input inside while read loop
Top Forums Shell Programming and Scripting input inside while read loop Post 80907 by Perderabo on Saturday 13th of August 2005 09:42:20 AM
Old 08-13-2005
read ENTER?"PRESS ENTER TO CONT..." </dev/tty 2>/dev/tty
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

read inside a while loop

Hi all, In a while loop, like below... while read line do read choice case $choice in 1) echo "xxx" esac done < file why I can't run the read choice???? (3 Replies)
Discussion started by: dta4316
3 Replies

2. UNIX for Dummies Questions & Answers

read user input from within a wile loop that is being fed from below

hi! i need to do a ksh script that uses a wile loop that is fed form below while read line do some things done < myfile inside the while loop i need to read user input to ask the user what he wants to do, but "read" reads the file, and not the standard input while read line do ... (2 Replies)
Discussion started by: broli
2 Replies

3. 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

4. UNIX for Dummies Questions & Answers

Getting user input from inside a while loop?

I'm new to BASH and i'm trying to create a script which is simply put a large find and replace file. This is what I have so far N=0 while read LINE ; do N=$((N+1)) sed 's/'$2'/'$3'/g' $LINE > .temp echo "Changes to file $N = $LINE" echo 'The following changes... (5 Replies)
Discussion started by: Azumandious
5 Replies

5. 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

6. 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

7. 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

8. Shell Programming and Scripting

ksh loop to read input until QUIT

Hi I'm looking to write a simple ksh loop reading user input (and write it to a file) until the user enters QUIT at which point I want it to continue. Does anyone have an example of this type of loop? Any help much appreciated Cheers (2 Replies)
Discussion started by: Grueben
2 Replies

9. Shell Programming and Scripting

Unable to read user input inside a loop

Hi, This query is a part of a much more lengthy script. I wish to look for all the files in a folder named "data" which in this case has two files i.e. plan.war and agent.properties. For all the files found under data I wish to ask the user as to where they wish copy the files to. Below,... (14 Replies)
Discussion started by: mohtashims
14 Replies

10. Shell Programming and Scripting

Read file input in while loop does not work on AIX system

I'm working on Aix 6.1 and using ksh shell. The below works fine on Linux bash or ksh shell . while IFS= read -r dirpath ; do echo "Hi" done <<<"$var" However, any such while loop that reads the input from file or variable using <<< fails on Aix system with the below error: Below... (2 Replies)
Discussion started by: mohtashims
2 Replies
HSEARCH(3)						     Linux Programmer's Manual							HSEARCH(3)

NAME
hcreate, hdestroy, hsearch - hash table management SYNOPSIS
#include <search.h> int hcreate(size_t nel); ENTRY *hsearch(ENTRY item, ACTION action); void hdestroy(void); #define _GNU_SOURCE #include <search.h> int hcreate_r(size_t nel, struct hsearch_data *tab); int *hsearch_r(ENTRY item, ACTION action, ENTRY **ret, struct hsearch_data *tab); void hdestroy_r(struct hsearch_data *tab); DESCRIPTION
The three functions hcreate, hsearch, and hdestroy allow the user to create a hash table (only one at a time) which associates a key with any data. The three functions hcreate_r, hsearch_r, hdestroy_r are reentrant versions that allow the use of more than one table. First the table must be created with the function hcreate(). The argument nel is an estimate of the maximum number of entries in the ta- ble. The function hcreate() may adjust this value upward to improve the performance of the resulting hash table. The corresponding function hdestroy() frees the memory occupied by the hash table so that a new table can be constructed. The argument item is of type ENTRY, which is a typedef defined in <search.h> and includes these elements: typedef struct entry { char *key; void *data; } ENTRY; The field key points to the NUL-terminated string which is the search key. The field data points to the data associated with that key. The function hsearch() searches the hash table for an item with the same key as item (where "the same" is determined using strcmp(3)), and if successful returns a pointer to it. The argument action determines what hsearch() does after an unsuccessful search. A value of ENTER instructs it to insert a copy of item, while a value of FIND means to return NULL. RETURN VALUE
hcreate() and hcreate_r() return 0 when allocation of the memory for the hash table fails, nonzero otherwise. hsearch() returns NULL if action is ENTER and the hash table is full, or action is FIND and item cannot be found in the hash table. hsearch_r() returns 0 if action is ENTER and the hash table is full, and nonzero otherwise. ERRORS
ENOMEM Out of memory. CONFORMS TO
The functions hcreate, hsearch, and hdestroy are from SVID, and are described in POSIX 1003.1-2001. The functions hcreate_r, hsearch_r, hdestroy_r are GNU extensions. BUGS
SVID and POSIX 1003.1-2001 specify that action is significant only for unsuccessful searches, so that an ENTER should not do anything for a successful search. The libc and glibc implementations update the data for the given key in this case. Individual hash table entries can be added, but not deleted. EXAMPLE
The following program inserts 24 items in to a hash table, then prints some of them. #include <stdio.h> #include <search.h> char *data[] = { "alpha", "bravo", "charlie", "delta", "echo", "foxtrot", "golf", "hotel", "india", "juliet", "kilo", "lima", "mike", "november", "oscar", "papa", "quebec", "romeo", "sierra", "tango", "uniform", "victor", "whisky", "x-ray", "yankee", "zulu" }; int main() { ENTRY e, *ep; int i; /* starting with small table, and letting it grow does not work */ hcreate(30); for (i = 0; i < 24; i++) { e.key = data[i]; /* data is just an integer, instead of a pointer to something */ e.data = (char *)i; ep = hsearch(e, ENTER); /* there should be no failures */ if (ep == NULL) { fprintf(stderr, "entry failed "); exit(1); } } for (i = 22; i < 26; i++) { /* print two entries from the table, and show that two are not in the table */ e.key = data[i]; ep = hsearch(e, FIND); printf("%9.9s -> %9.9s:%d ", e.key, ep ? ep->key : "NULL", ep ? (int)(ep->data) : 0); } return 0; } SEE ALSO
bsearch(3), lsearch(3), tsearch(3), malloc(3) GNU
2001-12-26 HSEARCH(3)
All times are GMT -4. The time now is 06:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy