Each select
statement needs to be completed before moving on to the next one. A select
statement is actually a special type of loop.
Let's say that I have a set of files, examplefile01
through examplefile10
. If I had a script like this:
select f in example*; do
echo "You selected $f"
break
done
It would look like this in execution:
$ ./470595.sh
1) examplefile01 4) examplefile04 7) examplefile07 10) examplefile10
2) examplefile02 5) examplefile05 8) examplefile08
3) examplefile03 6) examplefile06 9) examplefile09
#? 5
You selected examplefile05
The break
statement is important, because otherwise the select
statement would loop back to presenting the options again.
So in your case, you might want something like:
echo "Please Select the Show interface status file"
select FILE1 in *; do
cat "$FILE1" >> outputfile1
break
done
echo "Please Select the Show Vlan file"
select FILE2 in *; do
cat "$FILE2" >> outputfile2
break
done
You can also get a little clever and eschew the echo
statements by modifying the prompt provided by the select
statement by setting PS3:
PS3="Please Select the Show interface status file )"
select FILE1 in *; do
cat "$FILE1" >> outputfile1
break
done
PS3="Please Select the Show Vlan file )"
select FILE2 in *; do
cat "$FILE2" >> outputfile2
break
done
Also, since you're planning on combining the files, it might be easier to do that at the same time as the final selection:
PS3="Please Select the Show interface status file )"
select FILE1 in *; do
break
done
PS3="Please Select the Show Vlan file )"
select FILE2 in *; do
cat "$FILE1" "$FILE2" > outputfile
break
done