Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

"effective awk programming" book has an example on Field-Splitting. here is the example:

If you want fields to be separated by a literal period followed by any single character, use ‘FS = "\\.."’.

Why it is double backslash? shouldn’t it be \..?

share|improve this question
up vote 6 down vote accepted

Both string and regular expressions in awk share many of the same backslash escapes, including \\ for a single \. Since FS is a string value that is internally interpreted as a regular expression, those shared escapes have to be escaped twice. Thus \\ in a string becomes \ by the time it is interpreted as a regular expression.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.