Ping Phoenix

Discussion in 'Linux / Unix Discussion' started by ffreeloader, Oct 13, 2005.

  1. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    In the following output from a bash shell I get some behavior I don't quite understand. The variable $a is a="^H^H" which is actually two Control-H's. (To insert two visible Control-H's you have to hit Control-V first, continue to hold down the Control key and hit the H, then the V and then the H once more.) The Control-H character in a bash shell is a "destructive" backspace, i.e. same as the backspace key.

    Can you, Phoenix, or anyone else, explain why I get the output I do from the following? I don't understand why the number of empty spaces before the trailing " makes a difference in the output.

    While the formatting here doesn't show the spaces in the output and input very well, there are actual empty spaces in the output.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  2. Phoenix
    Honorary Member

    Phoenix 53656e696f7220 4d6f64

    5,749
    200
    246
    i honestly couldnt tell you freddy mate, you probably know more about bash than me, i'll ask around though mate
    let us know if you find out in the mean time!
     
    Certifications: MCSE, MCITP, VCP
    WIP: > 0
  3. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Well, I was sorta counting on you. I figured if there was anyone around who would know the bash shell pretty well it would be you, seeing how you're a Gentoo guy. We all know that Gentoo guys are the real geeks so.... :(
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  4. d-Faktor
    Honorary Member

    d-Faktor R.I.P - gone but never forgotten.

    810
    0
    39
    what is the output when you put braces around your variable letter, like so: ${a}
     
  5. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    d-Faktor,

    What follows is starts with 1 space and ends up with thee spaces before the trailing ". Expansion doesn't really seem to make much difference.

     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  6. d-Faktor
    Honorary Member

    d-Faktor R.I.P - gone but never forgotten.

    810
    0
    39
    ${a}, not {$a}
    you enclose your variable, so that any other characters are not taken into consideration when echoing a double quoted line.
    i'm not saying it will change anything for your example, but that's the way i've always used it.
     
  7. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    d-Faktor,

    Welll, I see my dyslexia is acting up again.... :oops:

    I got the same output when I actually used the correct expansion syntax, ${a}, as I did with the original syntax. No change whatsoever.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.