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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:41:58+00:00 2026-05-31T10:41:58+00:00

I have the following line at the first line in my script file: #!/bin/sh

  • 0

I have the following line at the first line in my script file:

#!/bin/sh

So I’m using csh.(?)

I wanto assign the output of the following to an environment variable:

echo $MYUSR | awk '{print substr($0,4)}'

I try:

set $MYVAR = echo $MYUSR | awk '{print substr($0,4)}'

But it doesn’t work,
How can I do it? I want to do it in a sh file.

  • 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-31T10:41:59+00:00Added an answer on May 31, 2026 at 10:41 am

    Your script should look like

     #!/bin/csh
    
     set MYVAR = `echo $MYUSR | awk '{print substr($0,4)}'`
    
     echo $MYVAR
    

    I don’t have a way to test this right now, let me now if it doesn’t work.


    If you’ve inherited the basis of your script from someone else, with the #!/bin/sh,
    then you have to find out if /bin/sh is really the bourne shell, or if it is a link to /bin/bash

    You can tell that by doing

       ls -l /bin/sh /bin/bash
    

    if you get back information on files where the size is exactly the same, the you’re really using bash, but called as /bin/sh

    So try these 2 solutions

       MYVAR=$(echo $MYUSR | awk '{print substr($0,4)}')
       echo $MYVAR
    

    AND

       MYVAR=``echo $MYUSR | awk '{print substr($0,4)}``  
       echo $MYVAR
    
       # arg!! only one pair of enclosing back-ticks needed, 
       # can't find the secret escape codes to make this look exactly right.
    

    in all cases (csh) included, the back-ticks AND the $( ... ) are known as command substitution.
    What every output comes from running the command inside, is substituted into the command line AND then the whole command is executed.

    I hope this helps.

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

Sidebar

Related Questions

I have a csv file with the following structure : The first line is
I have the following line in my IsapiRewrite.ini file: RewriteRule ^/test-url.asp$ http://www.google.co.uk/ [R=301,L] But
I have the following example file /etc/sysconfig/network/script.sh = -exe $Builder run_installation 123 44 556
I have the following Perl script with is meant to indent a XML file
I have a shell script like this. line=$@ # get the complete first line
So I have the following little script to make a file setup for organizing
I am using Codeigntier and I have the following dropdown in my view file
I have following line code in my view: <td> Model.some_instance_method(args) </td> I would like
I have following line of code to generate local notification after every 1 minute
I have the following line of code in javascript: (Math.random() + ) * 1000000000000000000

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.