Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Viewing all articles
Browse latest Browse all 102

using awk to find special charecters in txt file

$
0
0

I need to scan a file with many different special charecters and values.Given a set of special charecters - I need to provide the value next to it:

547 %$ 236 \"4523 &* 8876 (*8756 "/...

I am using an awk command with gsub in order to find the sequences as they are.

awk -v st="$match_string"'BEGIN {gsub(/(\[|\]|\-|\$|\*|\:|\+|\"|\(|\))/,"\\\\&", st)} match($0,st) {print;exit}' file.txt

The command works great e.g.

> (*>> 8876 (*

However I am having trouble using the command to locate the \" sequenceI am trying to add to the gsub different strings to represnt the sequence:

|\\||\\\\||\\\\"|...

But the result is always:

> \">> 8756 "/

It seems that the gsub does not work, and the \" is interpeted just as "Any ideas?


Viewing all articles
Browse latest Browse all 102

Trending Articles