Sorry for asking such a simple question, but reading about this issue on the internet has proven fruitless. I'm trying to better understand the grave/backtick operator and I've been doing okay so far except on one occasion.
Suppose I have a bash script and a variable in it, like so:
var=`ls -al | grep '^...x'
Now, the script requires the user to enter something and based on what that something is, it outputs a result. So, without boring you with the full script, I want to boil it down to one question. If the user inputs "-t" as an argument, the script needs to print all the .txt files that can be executed by the user, i.e, something like:
$var | grep '\.txt$'
Now, the problem arises when I try to reassign the value of var. I tried doing:
var=`$var | grep '\.txt$'`
but this doesn't work. I am not sure what I'm missing here, what is the proper way to deal with this?