creating unique lists from user input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting creating unique lists from user input
# 1  
Old 11-19-2005
creating unique lists from user input

hi all,

I'm trying to resolve a scenario where we prompt the user to enter 1 or more disk names.

From there we would run a command on each disk which would give its location.

This would allow us to create a list of disks at location A, a list of disks at location B,....etc...

Any help on creating these multiple lists?

script would do something like:


Enter disk(s): disk1 disk2 disk3 disk4

# behind the scenes we would run something like
# get_location disk1 (for each disk)
# which returns something like NY, Florida, etc...
# would set up the unique lists here
# then give back to user

Disks disk1 disk2 are at location Florida
Disk disk3 is at location NY
Disk disk4 is at location Boston

Our scenerio is a little more complicated than this but I wanted to get it down to the most basic example I could to make the question easier to ask.

Any suggestion on how to build these unique lists in my shell script?
(sadly we can't use perl here as its cross platform...etc..)

thanks
Annie
# 2  
Old 11-20-2005
printf "Enter disk list: "
read a
set "$a"
while [ -n "$1" ] ; do
echo Working on $1; shift
(...do whatever work you need to do...)
done

-Mike
P.S. Don't make the user do too much work. They should be able to enter "1", "2", "3", etc. You can do the rest; example...
printf "Enter disk list: "
read a
set "$a"
while [ -n "$1" ] ; do
disk="disk$1"
echo Working on $disk; shift
(...do whatever work you need to do...)
done

Last edited by mschwage; 11-20-2005 at 01:24 AM.. Reason: Another thought...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count Unique values from multiple lists of files

Looking for a little help here. I have 1000's of text files within a multiple folders. YYYY/ /MM /1000's Files Eg. 2014/01/1000 files 2014/02/1237 files 2014/03/1400 files There are folders for each year and each month, and within each monthly folder there are... (4 Replies)
Discussion started by: whegra
4 Replies

2. UNIX for Dummies Questions & Answers

Creating a new directory by getting input from user

Hi All, I am really new to Linux.I am trying to write a script for creating a new directory by getting input of folder name from the user.Please help me in this regard. #! /bin/bash echo "Enter name of dir":$filename mkdir -p $filename When executing this I am getting following error ... (13 Replies)
Discussion started by: Pradeep_1990
13 Replies

3. Shell Programming and Scripting

Identifying dupes within a database and creating unique sub-sets

Hello, I have a database of name variants with the following structure: variant=variant=variant The number of variants can be as many as thirty to forty. Since the database is quite large (at present around 60,000 lines) duplicate sets of variants creep in. Thus John=Johann=Jon and... (2 Replies)
Discussion started by: gimley
2 Replies

4. Shell Programming and Scripting

Creating array with non-duplicate / unique elements in ksh

Hi all, I have created 3 arrays which can have common elements in each like- arr_a contains str1 str2 str3 str4 str5 arr_b contains str3 str6 str7 str1 str8 arr_c contains str4 str9 str10 str2 each array is created with "set -A arr_name values" command. I want to create a resultant array-say... (1 Reply)
Discussion started by: sanzee007
1 Replies

5. Shell Programming and Scripting

Creating a script requiring a pause for user input

Hi I'm trying to create a basic script that pauses for user input to verify a file name before generating the output. I have numerous SSL certificate files which I am trying to determine the expiry date so what I'm trying to do is write a script so that is pauses to request the name of the .pem... (9 Replies)
Discussion started by: Buddyluv
9 Replies

6. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

7. Shell Programming and Scripting

Shell Script to Create non-duplicate lists from two lists

File_A contains Strings: a b c d File_B contains Strings: a c z Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below. Resultant... (7 Replies)
Discussion started by: mlv_99
7 Replies

8. Linux

help creating mailing lists

hey everyone ..i wanted to know how to create mailing lists with sendmail and postifx and wanted to know about mailmans ...would be nice if some has used mailman.. (0 Replies)
Discussion started by: tarunicon
0 Replies

9. Programming

Creating a Unique ID on distributed systems

Hi, How do you actually create a unique ID on a distributed system. I looked at gethostid but the man page says that its not guaranteed to be unique. Also using the IP address does not seem to be a feasible solution. Is there a function call or mechanism by which this is possible when even the... (4 Replies)
Discussion started by: pic
4 Replies
Login or Register to Ask a Question