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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:47:38+00:00 2026-06-15T07:47:38+00:00

I have a couple of servers on my development machine. I have a script

  • 0

I have a couple of servers on my development machine. I have a script each to run them and I am working on a few git branches at a time. So whenever I am running the script that runs the server, I want it to print which server from which branch of git I am trying to run in a different color.

Here is what I have but it is not working properly.

git_branch= git branch|grep '*'|cut -c3-
echo -e "\e[1;33;40m Running API server on git branch  $git_branch \e[0m"
...
REST_OF_THE_CODE_THAT_RUNS_THE_DEV_SERVER
...

It prints the git branch first and the value does not seem to be assigned to the variable at all. I am not able to figure out where I am going wrong

  • 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-15T07:47:40+00:00Added an answer on June 15, 2026 at 7:47 am

    To assign the result of a command line to a variable, use backquotes or $(..) notation. For example, assuming your command line works, you could use:

    git_branch=$(git branch|grep '*'|cut -c3-)
    

    This notation is preferable to backquotes because it’s more easily readable, and allows nesting without the need to escape things:

    echo $(echo foo$(echo bar))
    

    Note that in your original code, your grep should be more specific. Remember that an asterisk really means “zero or more of the previous atom”, to grep. So this would be better:

    git_branch=$(git branch|grep '^[*]'|cut -c3-)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of servers each that have a 'screen' that is running
I have a couple of servers and a load balancer. I want to show
I have built a few custom applications that run on WSS 3 using the
I have a small .NET WinForms application, and couple of linux servers, DEV and
I have run into problems getting my local php and rails development environments to
I have a development server and a couple of production ones. I do commits
I have just started HTML5 game development, I made a couple of games using
I have a SQL server and couple Windows clients and cache of some tables
I have a fairly basic TCP server keeping track of a couple connections and
I have a python server that listens on a couple sockets. At startup, I

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.