I have script that looks like this
#!/bin/bash
#exampel inputfile is "myfile.txt"
inputfile=$1
basen=`basename $inputfile .txt` # create basename
cat $inputfile |
awk '{print $basen "\t" $3} # this doesn't print "myfile" but the whole content of it.
What I want to do above is to print out in AWK the variable called 'basen' created before. But somehow it failed to do what I hoped it will.
So for example myfile.txt
contain these lines
foo bar bax
foo qux bar
With the above bash script I hope to get
myfile bax
myfile bar
What's the right way to do it?