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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:35:04+00:00 2026-06-03T04:35:04+00:00

I am writing simple housekeeping script. this script contains following line of codes.This is

  • 0

I am writing simple housekeeping script. this script contains following line of codes.This is a sample code i have extracted from the actual code since it is a big file.

 #!/bin/bash

 ARCHIVE_PATH=/product/file

 FunctionA(){
    ARCHIVE_USER=user1  # archive storage user name (default)
    ARCHIVE_GROUP=group1    # archive storage user group (default)

    functionB
 }

 functionB() {
    _name_Project="PROJECT1"
    _path_Componet1=/product/company/Componet1/Logs/
    _path_Component2=/product/company/Componet2/Logs/


     ##Component1##
     archive "$(_name_Project)" "$(_path_Componet1)" "filename1" "file.log" 
 }

 archive(){
     _name= $1
     _path=$2
     _filename=$3
     _ignore_filename=$4
     _today=`date + '%Y-%m-%d'`
     _archive=${ARCHIVE_PATH}/${_name}_$(hostname)_$(_today).tar
     if [ -d $_path];then
        echo "it is a directory"
     fi
 }

 FunctionA

When i run the above script , i get the following error

@localhost.localdomain[] $ sh testScript.sh
testScript.sh: line 69: _name_Component1: command not found
testScript.sh: line 69: _path_Component2: command not found
date: extra operand `%Y-%m-%d'
Try `date --help' for more information.
testScript.sh: line 86: _today: command not found
it is a directory

Could someone explain me what am i doing wrong here.

  • 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-03T04:35:06+00:00Added an answer on June 3, 2026 at 4:35 am

    Your variable expansions are incorrect — you’re using $() which is for executing a subshell substitution. You want ${}, i.e.:

     archive "${_name_Project}" "${_path_Componet1}" "filename1" "file.log" 
    

    As for the date error, no space after the +.

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

Sidebar

Related Questions

Writing a simple example from Odersky's book resulted in the following problem: // AbstractElement.scala
I'm looking into writing simple graphics code in Android and I've noticed some synchronized()
I writing a simple method which should delete an entity from the database if
I'm writing a simple custom function in Facelets with a sample method. The problem
I'm writing simple server/client in c, where server temporary stores message from client and
While writing a simple server-client application, this question came in my mind. When someone
I'm writing a (simple) compiler in Scala and have made the tokenizer iterable and
I am writing simple, unsophisticated web-server code in java. It seems to be finished,
I am writing simple blog with CodeIgniter and DataMapper and I have problem with
This is a really basic ruby gems question. I'm familiar with writing simple ruby

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.