GirlInTrouble
Technical User
Hi everyone
My head is getting to know the brick wall rather well by now.
My problem is all do to do with passing a list of files using the file command into a select loop. Now I can make the file command give me what I think works because I hard coded it into 2nd script, it doesn’t look pretty because it (input) is split over a number of lines.
It may be something to do with the way commands are parsed (which I don’t know ANYTHING about) or my not accounting for how tabs are pasted
I've stripped most of the junk out and this is just part of a script that I'm trying to make work.
Anyhow I’ve tried using xargs and eval anyhow this is the closest I’ve got to what I want
#VER=$(file * |sed 's/^/"/'|sed 's/ //g'|sed 's/$/" /' |sed 's/\n//')
#echo $VER
PS3="Select your file: "
select x in $(file * |sed 's/^/"/'|sed 's/ //g'|sed 's/$/" /'|sed 's/\n//') Exit
#`echo $VER` Exit
do
case "$x" in
*) return;;
Exit) return;;
esac
done
This doesn’t give me what I want, what it does is that it works for anything that doesn’t have spaces In it and it actually codes the “ into the option text! I know I went overboard with the SED and it HAS been worse, I managed to get it to write the “\” in as shown below. Anyhow its just getting stupid – I just can’t think of anything else. Any ideas???????
I mean I know select works with whatever you supply with “abc: def“
This is the hard coded version with a subset of the data pasted in (is that the problem?):
PS3="Please select your file: "
select x in "try: commands text" "try10: commands text" "try11: commands text" "try11b: commands text" "try12: commands text" "try2: commands text" "try4: assembler program text" "try5: commands text" "try6: commands text" "try7: assembler program text" "try8: assembler program text" "try9: commands text" Exit
do
case "$x" in
*) return;;
Exit) return;;
esac
done
My head is getting to know the brick wall rather well by now.
My problem is all do to do with passing a list of files using the file command into a select loop. Now I can make the file command give me what I think works because I hard coded it into 2nd script, it doesn’t look pretty because it (input) is split over a number of lines.
It may be something to do with the way commands are parsed (which I don’t know ANYTHING about) or my not accounting for how tabs are pasted
I've stripped most of the junk out and this is just part of a script that I'm trying to make work.
Anyhow I’ve tried using xargs and eval anyhow this is the closest I’ve got to what I want
#VER=$(file * |sed 's/^/"/'|sed 's/ //g'|sed 's/$/" /' |sed 's/\n//')
#echo $VER
PS3="Select your file: "
select x in $(file * |sed 's/^/"/'|sed 's/ //g'|sed 's/$/" /'|sed 's/\n//') Exit
#`echo $VER` Exit
do
case "$x" in
*) return;;
Exit) return;;
esac
done
This doesn’t give me what I want, what it does is that it works for anything that doesn’t have spaces In it and it actually codes the “ into the option text! I know I went overboard with the SED and it HAS been worse, I managed to get it to write the “\” in as shown below. Anyhow its just getting stupid – I just can’t think of anything else. Any ideas???????
I mean I know select works with whatever you supply with “abc: def“
This is the hard coded version with a subset of the data pasted in (is that the problem?):
PS3="Please select your file: "
select x in "try: commands text" "try10: commands text" "try11: commands text" "try11b: commands text" "try12: commands text" "try2: commands text" "try4: assembler program text" "try5: commands text" "try6: commands text" "try7: assembler program text" "try8: assembler program text" "try9: commands text" Exit
do
case "$x" in
*) return;;
Exit) return;;
esac
done