I work in support and am creating a script that allows a user to quickly gather information for diagnostic reasons.
I have multiple searches and choose to use the case method inside a .sh
main() {
#What we looking for?
echo "Whats broken? ( Key , Level, Bot, LPN, Variant, Starvation, Disconnects"
echo "entering \"helplist\" will print and list of available choices"
echo "Enter quit to quit or just control+c =-)"
read broken
#push to lowercase :p
broken2="${broken,,}"
#makes log files
case "$broken2" in
"stuck task")
echo "Task Number?"
read -r taskid
grep --color=auto "id=$taskid" "$engine"/TaskAssignment.txt | tee ~/$broken2.task$taskid.txt
;;
esac
printf "\n\n"
main
}
main
The tee itself works fine but I'd like to be able to generate the file based on the case and the argument passed into it.
How can you get the value of the case into the tee command read $case ?
$broken2contains a space, so because you didn't quote the arguments totee, you'll have two files -~/stuckand./task.task$taskid.txt. It's also wise to use the${var}syntax instead of$varwhen building a string, to be more precise variable naming. – Attie Aug 11 '20 at 19:17case ${broken2} intee ~/"${broken2}".$taskid.txt– Alex R Aug 11 '20 at 19:34"~/${broken2}.task${taskid}.txt"), and feel free to submit an answer :-) – Attie Aug 11 '20 at 19:47