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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:06:35+00:00 2026-05-26T09:06:35+00:00

We (the company I work for) need to run the find2perl script on over

  • 0

We (the company I work for) need to run the find2perl script on over a thousand different Unix servers of different flavors (Linux, Solaris, HP-UX, AIX) and different versions.

The one thing that all the servers have in common, is that they all have at least one implementation of perl installed. However, not all systems have it configured the same way.

Finding the location of perl is easy enough using the which command. However, on 70% of the servers, the actual directory containing find2perl (the bin folder of perl) is not present in the $PATH variable and can’t be located that way.

On some servers, perl is actually a symbolic link pointing another location, in which case I can use ls -l and sed to extract the target of the link to find where perl is actually installed.

On other servers however, it’s more complicated, as it seems perl was compiled to a custom location and the binary of perl present in /bin or /usr/bin (or wherever perl is found) is not a symbolic link, but rather a full blown executable. In this case, I thought about using the @INC variable of perl to try to find find2perl but it seems rather excessive.

What would be the better/best/fullproof method (one-liner if possible) to always get the location of find2perl on a Unix system?

  • 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-05-26T09:06:35+00:00Added an answer on May 26, 2026 at 9:06 am

    Ways to locate find2perl

    Two ways, both of which rely on asking the perl install how it was configured:

    Config.pm

    Its probably scriptdirexp from Config.pm.

    $ perl -MConfig -E 'say $Config{scriptdirexp}'
    /usr/bin
    

    And indeed, that’s where find2perl is on my system. You can use Config; in your perl scripts, which is its major advantage over the next method.

    perl -V:varname

    As per Yanick Girouard’s comment, you can also use perl -V:scriptdirexp to get this, in a format suitable to passing to eval in a shell script. There are actually several formats available (so, you don’t need to use e.g., cut to parse it):

    OPTION                 OUTPUT (\n = actual newline)     NOTES
    -V:scriptdirexp        scriptdirexp='/usr/bin';\n       full shell syntax, even if multiple -V options
    -V:scriptdirexp:       scriptdirexp='/usr/bin'          trailing colon omits semicolon and newline 
    -V::scriptdirexp       '/usr/bin'; \n                   extra leading colon omits var= part
    -V::scriptdirexp:      '/usr/bin'                       you can combine them.
    

    Full documentation is in the perlrun manpage.

    Ways to embed find2perl

    If you decide to copy over find2perl, as per evil otto’s comment, you can actually do that by embedding it in your shell script. There are many ways. If neither of the two below work, then you can certainly use shar (which has an extremely long history, and is likely compatible with everything).

    Quoted here-document

    The easiest way is if your shell supports quoted here-documents. They all should, as its a POSIX requirement:

    #!/bin/sh
    perl - -name 'foo' -mtime 2 -print <<'FIND2PERL'
    #!/usr/bin/perl
        eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
          if $running_under_some_shell;
    ⋮
    FIND2PERL
    

    Hex dump in a non-quoted here-document

    If some of your shells don’t implement quoted here-documents (POSIX‽ what’s that!), then you have to protect find2perl from shell expansion. An easy way is to hex dump it, as 0–9 and a–f are all safe from shell expansion. The dump is easily done with xxd -p /usr/bin/find2perl, which only requires xxd on one machine. To read back the dump, you can use plain perl:

    #!/bin/sh
    perl -n -e 'chomp; print pack("H*", $_)' <<HEX | perl - -name 'foo'
    23212f7573722f62696e2f7065726c0a202020206576616c202765786563
    202f7573722f62696e2f7065726c202d5320243020247b312b222440227d
    ⋮
    HEX
    

    Using find2perl several times

    Naturally, with either approach, you could also write find2perl to a temporary file (if you need to invoke it multiple times, for example). You could also embed it in a shell function.

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

Sidebar

Related Questions

The company I work for has over 1000 apps which we maintain. Many of
The company I work for produces a content management system (CMS) with different various
In the company where I came to work, they run a PHP/MySQL relational database.
The company I work for makes hardware that communicates to the computer though a
The company I work for is wanting to add blog functionality to our website
the company I work for want to use a hosted payment form to charge
The company I work for currently uses Go To Meeting to share our desktops
The company I work for has recently been hit with many header injection and
The company I work for has several clients. I'm currently splitting my time between
The company I work for has a large webapp written in C++ as an

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.