OK, to continue from my earlier message:
1.
"Yes, I did try "redirection" but it did not work as expected."
This is one of the most frustrating comments that we see in a question. We have no idea what you did expect to see or happen. And we have no idea what did happen. Without a clear explanation of what you expected and what result you received we cannot really help.
2. You are mixing command substitution and redirection, so it is not clear which is the big problem. Redirection is quite straightforward, it allows you to send the output of a command to a file instead of the console, so you can read it later in your editor. It also allows you to send the contents of a file as input to a command. So a command like:
ls -l > foo.txt
sends the output from the list command to the file foo.txt. You can also use the pipe
|
to send the output from one command as the input to another. Thus
ls -l | grep "foo"
sends the output of the ls command as input to grep, which will list all files that contain the string 'foo'.
3. As to command substitution, that uses the construct
$(command)
which runs
command
and replaces the
$(command)
in the script with the actual result of the command. So in your statement above
index=$(sed -n "/$choice/=" "$PWD$DEBUG_DIR$DEBUG_MENU")
you are setting the local variable
index
, to the result of the statements in the parentheses. Which is not the same as piping it into a file.