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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:33:22+00:00 2026-06-17T21:33:22+00:00

I am reading a shell scripts from github : script It has two lines

  • 0

I am reading a shell scripts from github :script

It has two lines of code confused me. I have never seen ## used in bash like this before.
could anyone explain this to me, how does it work? thanks.

branch_name=$(git symbolic-ref -q HEAD)
branch_name=${branch_name##refs/heads/}

Note:The first line produces something like ‘refs/heads/master’
and the next line remove the leading refs/heads make the branch_name becomes master.

  • 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-17T21:33:23+00:00Added an answer on June 17, 2026 at 9:33 pm

    From the bash(1) man page, EXPANSION section, Parameter Expansion subsection:

       ${parameter#word}
       ${parameter##word}
              Remove matching prefix pattern.  The word is expanded to produce
              a pattern just as in pathname expansion.  If the pattern matches
              the beginning of the value of parameter, then the result of  the
              expansion  is  the expanded value of parameter with the shortest
              matching pattern (the ``#'' case) or the longest  matching  pat‐
              tern  (the  ``##''  case)  deleted.
    

    Also available in the manual, of course (but it doesn’t seem to support linking to this exact text; search the page for ##).

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

Sidebar

Related Questions

I'm just a beginner in shell script. I'm reading the code of my co-worker
When the following two lines of code are executed in a bash script, ls
In my simple custom shell I'm reading commands from the standard input and execute
I have some web service + some shell scripts which I want to execute
I am trying to test some code. The main script requires imports from a
I have a shell script, That writes a content in to the file, #!/bin/bash
I have various shell build scripts for a project and want to create one
I've got half a C class and maybe one or two shell scripts I've
While reading about shell scripts and temporary file handling, I came across Symlink Exploits.
We have a shell script that expects multiple user inputs to be entered when

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.