I just want to use a awk command in my perl script like follows:
$linum = `awk -F "%" '/^\s*kernel/{print NR}' < $grubFile`;
But it will say: Unrecognized escape \s passed through at ./root line 36.
How do I avoid that? thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
makes no more sense than
If you want the two characters
\ands, you need to escape the\in double-quoted literals and similar. Just like you’d useyou need to use
Note that you completely fail to properly escape the contents of
$grubFiletoo. Your command will fail if the file name contains spaces. And consider what could happen instead if it contain other character special to shells, such as|.As @ysth showed, the following is equivalent to your command:
Getting rid of the input redirection means you could simply use
By the way, it’s not that hard to do it purely with Perl.