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 8418057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:12:50+00:00 2026-06-10T02:12:50+00:00

I want to run this command in perl for dir in *; do test

  • 0

I want to run this command in perl

for dir in *; do
 test -d "$dir" && ( find "$dir" -name '*test' | grep -q . || echo "$dir" );
 done

I have tried :

 system ("for dir in *; do
        test -d "\$dir" && ( find "\$dir" -name '*test' | grep -q . || echo "\$dir" );
        done");

but does not work .

  • 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-10T02:12:51+00:00Added an answer on June 10, 2026 at 2:12 am

    Your quoting is off.

    "for dir in *; do
        test -d "\$dir" && ( find "\$dir" -name '*test' | grep -q . || echo "\$dir" );
        done"
    

    You have decided to delimit your string with double quotes ", but they are included in your string.

    Either escape the other quotes:

    "for dir in *; do
        test -d \"\$dir\" && ( find \"\$dir\" -name '*test' | grep -q . || echo \"\$dir\" );
        done"
    

    (error prone, ugly)

    … or use another delimiter: Perl offers you a wide range of possibilities. These quoting syntaxes interpolate variables inside: "…" and qq{…} where you can use any character in [^\s\w] as delimiter, and non-interpolating syntaxes are: '…' and q{…} with the same delimiter flexibility as before:

    qq{for dir in *; do
        test -d "\$dir" && ( find "\$dir" -name '*test' | grep -q . || echo "\$dir" );
        done}
    

    The q and qq constructs can include the delimiter inside the string, if the occurrence is balanced: q( a ( b ) c ) works.

    The third quoting mechanism is a here-doc:

    system( <<END_OF_BASH_SCRIPT );
    for dir in *; do
        test -d "\$dir" && ( find "\$dir" -name '*test' | grep -q . || echo "\$dir" );
        done
    END_OF_BASH_SCRIPT
    

    This is usefull for including longer fragments without worrying about a delimitor. The String is ended by a predefined token that has to appear on a line of its own. If the delimitor declaration is placed in single quotes (<<'END_OF_SCRIPT'), no variables will be interpolated:

    system( <<'END_OF_BASH_SCRIPT' );
    for dir in *; do
        test -d "$dir" && ( find "$dir" -name '*test' | grep -q . || echo "$dir" );
        done
    END_OF_BASH_SCRIPT
    

    Note on the q{} and qq{} syntax: This is a feature never to be used outside of obfuscation, but it is possible to use a character in \w as the delimiter. You have to include a space between the quoting operator q or qq and the delimiter. This works: q xabcx and is equal to 'abc'.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run this as a batch rather than through the command line:
I want to run weka through the command line. I type in this command:
I want to do this: run a command capture the output select a line
I have written php program and uploaded on server. I want run this program
I want to run this PHP function -- $querystring_arr='maxResults=50&startIndex=50&sort=date'; $str=preg_replace((&startIndex=)?[0-9]*(&)?,&startIndex=.$sindex.&,$querystring_arr); When I print $str
I want to run some commands using the system() command, I do this way:
For example I am using ffplay and want to run this command -bufsize[:stream_specifier] integer
I have a sed command that I want to run on a huge, terrible,
I have a perl script which when run from the command line generates a
Why this code don't work,when i want run this code vwd 2008 express show

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.