Frage

I am trying to run the script which was in the solaris in the linux machine. It's showing warnings nawk: cmd. line:7: warning: escape sequence\<' treated as plain <' I can't change the version of the awk. Is there any other way to remove this warning?

EDIT: My awk file will simply print the xml tags in function.

function PrintExamHeader()
{
 print "<exam";  #I have removed the \ 
}

Now it's giving warnings at line number where there is no such pattern.

  BEGIN {        # here it's giving warning
   OFS = "";

  # Indexes for series structure
  idx = 1;
  Number = idx++;
  ItDate = idx++;             # and 3 more at such lines 
  Time = idx++;
  Date = idx++;
War es hilfreich?

Lösung

Here's a simple example that triggers the warning (GNU awk; on some Linux systems, nawk is a symlink to GNU awk, gawk):

awk 'BEGIN { print "\<exam" }'  # -> '<exam'

If your output is OK, and all you need to do is to get rid of the warning, simply remove the \:

awk 'BEGIN { print "<exam" }'  # -> '<exam'

If instead you wanted to print \<exam, you'd have to double the backslash:

awk 'BEGIN { print "\\<exam" }'  # -> '\<exam'

What the warning is trying to tell you is that the \ prefix is essentially a no-op in this context, and that it is not needed.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top