I don't typically write in bash so there are probably a lot of errors but if you could help me with the multiple variable user input that would help!
Code:
#Location variables
TIME=" -maxdepth 1 -mtime +31"
RIG="/results/fakedir/"
EXTERNAL="/media/ExternalArchive/"
HOME="/results/analysis/output/Home/"
#Determines total amount of files found by the find query
RIG_COUNT=$(find ${RIG}${TIME} | wc -l)
EXTERNAL_COUNT=$(find ${EXTERNAL}${TIME} | wc -l)
HOME_COUNT=$(find ${HOME}${TIME} | wc -l)
let ID_COUNT=${RIG_COUNT}+${HOME_COUNT}
let TOTAL_COUNT=${RIG_COUNT}+${EXTERNAL_COUNT}+${HOME_COUNT}
#Finds files older than specified time
FIND_RIG=$(find ${RIG}${TIME})
FIND_EXTERNAL=$(find ${EXTERNAL}${TIME})
FIND_HOME=$(find ${HOME}${TIME})
#Puts the results of each of the "finds" into an array by its
#basename and extracts the unique ID of "SN-##"
#The "*_A" array holds the basename of a file, excluding the full pathname
#The "*_ID" array stores the unique IDs of the runs.
j=0
for a in ${FIND_RIG}
do
RIG_PATH[j]=${a}
RIG_ID[j]=`echo ${RIG_PATH[j]} | sed -e 's#.*\(SN2-\([0-9][0-9]\)\).*#\1#g'`;
let j++
done
j=0
for b in ${FIND_EXTERNAL}
do
EXTERNAL_PATH[j]=${b}
EXTERNAL_ID[j]=`echo ${EXTERNAL_PATH[j]} | sed -e 's#.*\(SN2-\([0-9][0-9]\)\).*#\1#g'`;
let j++
done
j=0
for c in ${FIND_HOME}
do
HOME_PATH[j]=${c}
HOME_ID[j]=`echo ${HOME_PATH[j]} | sed -e 's#.*\(SN2-\([0-9][0-9]\)\).*#\1#g'`;
let j++
done
#Creates an array with all of the unique IDs in it.
OLDIFS="$IFS"
IFS=$'\n'
UNIQUERUNS=(`for i in "${RIG_ID[@]}" "${EXTERNAL_ID[@]}" "${HOME_ID[@]}" ; do echo "$i" ; done | sort -du`)
IFS="$OLDIFS"
#Checks to see if the unique ID exists in all directories.
#If the ID exists in all directories EXIST_COUNT will be 3.
for ((i=0; i<=${TOTAL_COUNT}; i++))
do
RIG_EXIST[i]=$(find "${RIG}"*"${UNIQUERUNS[i]}"* | wc -l)
HOME_EXIST[i]=$(find "${HOME}"*"${UNIQUERUNS[i]}"* | wc -l)
EXTERNAL_EXIST[i]=$(find "${EXTERNAL}"*"${UNIQUERUNS[i]}"* | wc -l)
let EXIST_COUNT[i]=${RIG_EXIST[i]}+${HOME_EXIST[i]}+${EXTERNAL_EXIST[i]}
done
echo -e "\nRun(s) to be deleted."
echo -e "\n******************************\n"
N=1
for ((i=0; i<=${TOTAL_COUNT}; i++))
do
if [ ${EXIST_COUNT[i]} = 3 ]
then
BASE=("${RIG}"*"${UNIQUERUNS[i]}"*)
echo $N ${BASE##*/}
I_COUNT[N]=${BASE}
let N++
fi
done
#echo ${I_COUNT[@]}
echo -e "\n******************************\n"
echo "Would you like to keep any found files? (y/n)"
read USER_ANSWER
while [ ${USER_ANSWER} == "y" ]
do
echo "Type the number associated with the run(s) to be kept."
read USER_NUM
if [ $USER_NUM -gt ${#I_COUNT[@]} -o $USER_NUM -le 0 ]
then
echo -e "Invalid run."
else
echo -e "\nKeeping: " ${I_COUNT[${USER_NUM}]}"\n"
#touch ${I_COUNT[${USER_NUM}]}
echo -e "Removing "${I_COUNT[@]}
break
fi
done
if [ ${USER_ANSWER} == "n" ]
then
echo -e "\nDeleting runs "${I_COUNT[@]}
#rm -r ${I_COUNT[@]}
fi
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)
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)
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)
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)
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)
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)
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)
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 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)
Discussion started by: bedtime
4 Replies
LEARN ABOUT DEBIAN
evtest-capture
EVTEST-CAPTURE(1)EVTEST-CAPTURE(1)NAME
evtest-capture - Input device event capture program
SYNOPSIS
evtest-capture "/dev/input/eventX" [evtest-capture.xml]
DESCRIPTION
evtest-capture captures the information and events from the input device specified on the command line and writes it to the xml file given.
If no filename is given for the output file, evtest-capture.xml is chosen as default.
evtest-capture needs to be able to read from the device; in most cases this means it must be run as root.
Together with with evtest-create-device.xsl, a simple uinput-based software input device can be created that replays the events as if the
same input was performed on the physical device. This can be useful to replicate bugs with input devices in upper layers of the stack.
To convert evtest-capture.xml into such a uinput device, run:
xsltproc evtest-create-device.xls evtest-capture.xml > mydevice.c
gcc -o mydevice mydevice.c
./mydevice
DIAGNOSTICS
If evtest-capture does not see any events even though the device is being used, the device may be grabbed by a process (EVIOCGRAB). This is
usually the case when debugging a synaptics device from within X. VT switching to a TTY or shutting down the X server terminates this grab
and synaptics devices can be debugged.
SEE ALSO evtest(1)AUTHOR
evtest-capture was written by Peter Hutterer <peter.hutterer@redhat.com[1]>.
NOTES
1. peter.hutterer@redhat.com
mailto:peter.hutterer@redhat.com
05/21/2012 EVTEST-CAPTURE(1)