I am trying to create a shell script, below is a part of which where i am trying to extract some value from a record in a file:
tgt_val=cat $file_name | grep "$string_name" | cut -d"|" -f$column_no
This work perfectly when the specified column has some numeric or string value however it fails when the column has value as *
, eg:
102|Sam|*|USA
This command would work correctly for column 1, 2 & 4
However in case of column 3 it gives me output as all the files in present directory.
Someone please help over this.
It was a problem with my $tgt_val. It worked when i echo'ed the value as echo "$tgt_val"