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

  • Home
  • SEARCH
  • 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 8867143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:57:32+00:00 2026-06-14T16:57:32+00:00

DATE1=`perl -e ‘use POSIX qw(strftime); print strftime %Y-%m-%d,localtime(time()- 3600*72);’` DATE2=`perl -e ‘use POSIX qw(strftime);

  • 0
DATE1=`perl -e 'use POSIX qw(strftime); print strftime "%Y-%m-%d",localtime(time()- 3600*72);'`

DATE2=`perl -e 'use POSIX qw(strftime); print strftime "%Y%m%d",localtime(time()- 3600*72);'`

DATE3=`perl -e 'use POSIX qw(strftime); print strftime "%Y%m%d",localtime(time()- 3600*48);'`

DATE4=`perl -e 'use POSIX qw(strftime); print strftime "%Y/%m/%d",localtime(time()- 3600*48);'`

Below is my shell script(test1.sh), in which I need to print four dates and all those four dates should come from above. Meaning I need to pass above those four dates from the command prompt only to the below shell script.

#!/bin/bash

echo Date1
echo Date2
echo Date3
echo Date4

So when I am running the shell script like this- it should get Date1, Date2, Date3, Date4 from the above four dates?

sh -x test1.sh Date1 Date2 Date3 Date4

Is it possible to do in shell script?

  • 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-14T16:57:34+00:00Added an answer on June 14, 2026 at 4:57 pm

    If you execute your first code-block in a shell, then you’ll have defined 4 variables with the output of those commands. To access any of those variables, you have to prepend a $ to the variable name – say, $DATE1.

    So, for running your script with those parameters, you should run:

     bash -x test1.sh $DATE1 $DATE2 $DATE3 $DATE4
    

    Pay attention to the $ and the case-sensitiveness.

    Finally, in your script, arguments are received in a family of variables that are called with the number of order of the parameter. So, your first parameter is retrieved by $1, the second by $2, and so on.

    So, your script ends up being:

    #!/bin/bash
    
    echo $1
    echo $2
    echo $3
    echo $4
    

    Watch also that you are defining a she-bang that tells the script to be interpreted by bash, but your previous invocation was using sh. They have lots of compatibilities, but they are not the same.

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

Sidebar

Related Questions

I've used the localtime function in Perl to get the current date and time
For example: DateTime date1 = new DateTime(1955, 12, 12); DateTime date2 = new DateTime(1967,
This is the perl code ... use strict; use warnings; use LWP::UserAgent; use HTTP::Date;
When writing Perl scripts I frequently find the need to obtain the current time
I want Perl to display current date and time in the following format: 2010-02-11
I have a very short tutorial perl script: #!/usr/bin/perl print The date is ,`date`;
This code finds the difference between today and a fixed date. #!/usr/bin/perl use strict;
In the below perl script, I check my folder name (which is in the
How can I elegantly print the date in RFC822 format in Perl?
I am trying to convert a date/time GMT 0 to GMT -6 in Perl.

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.