Reputation:
tab="`\echo '\t'`"
grep "^.*${tab}.*${tab}.*${tab}.*${tab}.*${tab}" $file |
grep -vi ssm_id |
cut -f 1,5,6 -d "${tab}" > $rmloadfile
I am getting error as
-cut: invalid delimiter
the above code is part of my bash script.
Upvotes: 0
Views: 1766
Reputation: 532538
Ignoring the actual problem, you really want to use awk
here instead of this combination of grep
and cut
:
awk 'NF>=6 && tolower($0) !~ ssm_id { print $1, $5, $6 }' $file > $rmloadfile
Upvotes: 3
Reputation: 4519
The echo
command doesn't interpret backslash escaped characters by default. It has to be enabled using the -e
switch.
If you use:
tab="$(echo -e '\t')"
it works.
But I'd rather recommend using the approach proposed by @devnull in the comments, or refer to the linked question.
Upvotes: 2