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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:32:00+00:00 2026-06-05T04:32:00+00:00

i have a shell script script.sh which gives output as success or Failed when

  • 0

i have a shell script “script.sh” which gives output as “success” or “Failed” when i execute in unix window.
Now i want to store the output of script.sh into a unix command variable. say $a = {output of script.sh}

  • 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-05T04:32:01+00:00Added an answer on June 5, 2026 at 4:32 am

    Two simple examples to capture output the pwd command:

    $ b=$(pwd)
    $ echo $b
    /home/user1
    

    or

    $ a=`pwd`
    $ echo $a
    /home/user1
    

    The first way is preferred. Note that there can’t be any spaces after the = for this to work.

    Example using a short script:

    #!/bin/bash
    
    echo "hi there"
    

    then:

    $ ./so.sh
    hi there
    $ a=$(so.sh)
    $ echo $a
    hi there
    

    In general a more flexible approach would be to return an exit value from the command and use it for further processing, though sometimes we just may want to capture the simple output from a command.

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

Sidebar

Related Questions

I have been trying to execute the following UNIX shell script which is not
I have a unix shell script which test ftp ports of multiple hosts listed
i have unix shell script which is need to be run like below test_sh
I have a shell script which I want to run without using the sh
I have a shell script which outputs all of the .js and .html files
Hi I have a shell script which should run based on the return of
I have a shell script, which is run under a opensuse linux, that starts
I have a shell script with a lot of echo statements. I want to
I've never done shell script before and now I'm running into a simple problem...
I want to write a shell script which will find the occurence of multiple

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.