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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:32:04+00:00 2026-05-20T19:32:04+00:00

Here’s my high level problem. I want to read a number max_age_in_secs from a

  • 0

Here’s my high level problem.

I want to read a number max_age_in_secs from a config file. This number represents the number of seconds we consider a file is “old”. After we read this config, we want to search all files in a directory data and delete all files modified before max_age_in_secs seconds ago.

This has to be done as a shell script, more specifically korn shell.

What I’m doing right now is to touch a dummy file to be modified max_age_in_secs ago, then use find and its ! -newer option to search for files older than that.

I’m having a problem getting a timestamp to pass to touch. The date command on my unix box doesn’t have the option --date so I can’t use that.

I’m looking at perl -e "blah_blah_blah" but I need to pass the max_age_in_secs variable to the perl command. The only way I know to do that is creating a new .pl file and pass arguments to that file. But ideally I would like to have this functionality in one korn script file. A workaround may be constructing a perl_command variable, and execute its content, but I think that’s not secure and vulnerable to injections.

But I’m relatively new to shell scripting and perl, so any help is appreciated.

  • 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-20T19:32:05+00:00Added an answer on May 20, 2026 at 7:32 pm

    There is more than one way to pass an environment variable from a shell to a one-line perl command:

    • Directly. Most shells (including korn) interpolate expressions inside double quotes.
    perl -e "print $VAR"
    

    so in this case $VAR is coming from the shell. This technique has a lot of shortcomings, namely that with an `-e “double quoted expression” it is a pain to use other Perl variables or use a lot of other useful Perl constructions that might be misconstrued by the shell.

    • As a command line argument, accessed in the perl script in @ARGV
    perl -e 'print "VAR is $ARGV[0]"' $VAR
    

    This will do if you don’t need to use @ARGV (which are implicitly used if you use the -p or -n switches, or if your program uses the default <> operator).

    • Through Perl’s %ENV hash.
    perl -e 'print "VAR is $ENV{VAR}"'
    

    This mechanism doesn’t interfere with @ARGV

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

Sidebar

Related Questions

Here is a complete example. I want to forbid using A::set from objects casted
Here is another spoj problem that asks how to find the number of distinct
Here's a coding problem for those that like this kind of thing. Let's see
Here's the context: I have a file (or stream), and I want to process
Here's my proposed (very simplified to illustrate the problem space) design for a C#
Here's what I want to do: Given a table PeopleOutfit (id int primary key,
Here's the method. I want to know if I am violating any best practices
Here's a Clone() implementation for my class: MyClass^ Clone(){ return gcnew MyClass(this->member1, this->member2); }
Here is my problem : I have a post controller with the action create.
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();

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.