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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:44:03+00:00 2026-05-31T16:44:03+00:00

Would you please explain why the following shell command wouldn’t work: sh-3.1$ echo $MYPATH

  • 0

Would you please explain why the following shell command wouldn’t work:

sh-3.1$ echo $MYPATH
/opt/Application/DATA/CROM/my_application
sh-3.1$ awk '{print substr($MYPATH,3)}'

Thanks
Best Regards

  • 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-31T16:44:04+00:00Added an answer on May 31, 2026 at 4:44 pm

    MYPATH is not going to be substituted by the shell since the string uses single quotes. Consider the following:

    csh$ echo '{print substr($USER,3)}'
    {print substr($USER,3)}
    csh$ echo "{print substr($USER,3)}"
    {print substr(dshawley,3)}
    

    The usage of single quotes instructs the shell to pass the string argument to the program as-is. Double quotes tell the shell to perform variable expansion on the argument before passing it to the program. This is a basic shell feature that is common amongst shells and some programming languages (e.g., perl).

    The next problem that you are going to run into is that awk will want quotes around the first parameter to substr or the parse will fail. You will probably see an “Illegal variable name” warning in this case. This is where I get lost with csh since I have no clue how to properly escape a double-quote within a quoted string. In bash/sh/ksh, you would do the following:

    sh$ awk "{print substr(\"$USER\",3)}"
    input
    ^D
    hawley
    sh$
    

    Just in case you do not already know this, awk will require an input stream before it is going to do anything. I had to type “input” and the EOF character for the little example.

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

Sidebar

Related Questions

Can anyone please explain me why would the following code print 20 instead of
Can you please explain following doubts? When my j2me application is listening for sms
Can someone please explain me why the following doesn't work, or give me a
Could someone please explain when would I want to use delegation instead of inheritance?
Please explain from Linux, Windows perspectives? I am programming in C#, would these two
I would like to access a MySQL database using PHP. Can someone please explain
Can someone please shed some light on how I would get this to work:
Can you, please, explain me the differences between the following database representatives, say, in
Can anyone please explain what the following two paragraphs mean, in simple english? (Taken
Can someone please explain how static variables in member functions work in C++. Given

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.