Reputation: 1210
I have a file:
CreateSec,explorer.exe,\\WINDOWS\\system32\\verclsid.exe,SUCCESS
I want to print "$2"
Example 1
It works well:
$ awk -F '\\\\\\\\' '{print $2}' file
WINDOWS
Example 2
It works well:
$ awk -F '\\\\'+ '{print $2}' file
WINDOWS
Example 3
Does not print.
$ awk -F "\\\\\\\\" '{print $2}' file
.
Example 4
So it works well:
$ echo "CreateSec,explorer.exe,\\WINDOWS\\system32\\verclsid.exe,SUCCESS" | awk -F '\' '{print $2}'
WINDOWS
----------------------------------------------------------------------------------
$ echo "CreateSec,explorer.exe,\\WINDOWS\\system32\\verclsid.exe,SUCCESS" | awk -F "\\" '{print $2}'
WINDOWS
Questions:
What is the difference between?:
a) awk -F '\\\\\\\\'
b) awk -F "\\\\\\\\"
Thank you for the explanation.
Upvotes: 1
Views: 689
Reputation: 753765
Regarding (3) — four backslashes is the difference:
awk
. awk
.Upvotes: 3