I need to capture multiple values from user input and do not know how to do it. I'm writing a script to delete old files, but want to give the option to keep some by asking the user.
This is what my output looks like...
Then this bit of code is run after the above is output to keep or delete files.
And from this point I prompt the user and ask which files they want to keep if any, and they select a number from the above output and it keeps that file. But I want to make it so the user can input more than one number for keeping the files, like typing 1 2 3 4 if they want to keep those four files.
How do I do this? I'm new to bash the more explanation contained in the answer the more I can learn
I would like to make a function or command that checks for keyboard input without interrupting the program and exits the program when a key is pressed (perhaps the 'q' key).
The program below monitors and prints/executes commands upon a change in primary (mouse selection) or clipboard buffer. If... (4 Replies)
Hi
I am pretty confused in returning and capturing multiple values
i have defined a function which should return values "total, difference"
i have used as
#!/usr/bin/ksh
calc()
{
total=$1+$2
echo "$total"
diff=$2-$1
echo "$diff"
}
I have invoked this function as
calc 5 8
Now i... (2 Replies)
I have a program that accepts user input. For example I have mdacc that the user sets the value. I then have a class which stores the value set by the user. I use set_param to set the values in the class. I pass through it the list of user defines arguments from argv. What would be the opinion on... (0 Replies)
Hello,
For the input file, I am trying to split those records which have multiple values seperated by '|' in the last input field, into multiple records and each record corresponds to the common input fields + one of the value from the last field.
I was trying with an example on this forum... (4 Replies)
Hi all.
I have the following command that is successfully searching for any one of the strings on all lines of a file and replacing it with the instructed value.
cat inputFile | awk '{gsub(/aaa|bbb|ccc|ddd/,"1234")}1' > outputFile
This does in fact replace any occurrence of aaa, bbb,... (2 Replies)
Hi
I want to accept multiple lines input with spaces from User and i have a working code like this.
char sRes;
char sReq;
printf("Please enter request:");
scanf("%",sReq); /* Accept the input from user */
printf("\nPlease enter response:");
scanf("%",sRes);
but the... (4 Replies)
Is there a way to display the default answer when accepting input from the user in the unix script..
e.g.
ans="n"
read $ans?"Enter y to continue n to exit:"
altough ans contains n the message doesn't display the current contents on ans .. you get
Enter y to continue n to exit: (8 Replies)
i have this basic line of code that doesn't work. i simply want to get the input parameter strings but when the script is run it appears that the first parameter is assigning the value to the second parameter.
#!/bin/sh
pdir=`pwd`
p1=$1
p2=$2
echo "directory: $pdir\n"
echo "parameter... (2 Replies)
Hi all,
I wrote a script that reads inputs from user and store in array named "input". The number of elements in the array is not fixed - determined only after user exit the while loop that reads the array values :
x=1
echo "Enter first value"
read input
while } != "exit" ]
do
... (1 Reply)