Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9136993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:01:56+00:00 2026-06-17T09:01:56+00:00

I just want to use a awk command in my perl script like follows:

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:01:57+00:00Added an answer on June 17, 2026 at 9:01 am
    $x = `... \s ...`;
    

    makes no more sense than

    $x = "... \s ...";
    

    If you want the two characters \ and s, you need to escape the \ in double-quoted literals and similar. Just like you’d use

    $x = "... \\s ...";
    

    you need to use

    $x = `... \\s ...`;
    

    Note that you completely fail to properly escape the contents of $grubFile too. 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:

    awk -F% '/^\s*kernel/{print NR}' "$grubFile"
    

    Getting rid of the input redirection means you could simply use

    use IPC::System::Simple qw( capturex );
    my @line_nums = capturex('awk', '-F%', '/^\s*kernel/{print NR}', $grubFile);
    chomp @line_nums;
    

    By the way, it’s not that hard to do it purely with Perl.

    my @line_nums;
    open(my $fh, '<', $grubFile) or die $!;
    while (<$fh>) { 
       push @line_nums, $. if /^\s*kernel/;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use DBMS_OUTPUT.PUT_LINE , but the number of rows exceeds just 1.
I just want use jstl:core with SpringMVC. My controller contain something like : private
I just want to use HttpUtility.UrlEncode(myString) . The project is .NET 3.5. But I
I just want to use a static page as frontpage, but it must be
I just want to use .NET Profiling API ( ICorProfilerCallback etc) but at the
I just want to use the iPhone system font but I can't figure out
I just want to use the like button and not show any comment popup.
I just want to use the boundaries of these polys for many calculations. But
I just want to use PHPWord for Symfony 2. But Im new on Symfony
I just want to use SQLite in a Java application. I found sqlitejdbc but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.