Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319

    sh and the single quote


    Code:
    echo 'Don\'t tell me this doesn\'t work'
    Under sh or bash, can anyone tell me why this resorts to my second prompt?
    The best things in life are free.

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Within single quotes, _nothing_ except the ending quote is recognized, not even backslash. Therefore, to accomplish that, you must use this:
    Code:
    echo 'Don'\'' tell me this doesn'\''t work'

  3. #3
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Hmm. I guess I better e-mail the author of this book. One of her examples does exactly what I wrote before.
    The best things in life are free.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I'm absolutely not sure, but I have a faint memory that I actually have used that technique before, in an older version of bash, so maybe they have deleted that functionality after the book was released. I might very well remember it all wrong, though. Try mailing her; she might know the truth behind it.

  6. #5
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    I was doing this kind of thing in RedHat 7.3 and I don't recall this giving me a problem. Of course I was using bash instead of ash at the time (since I never installed sh) but don't recall it giving me a problem. Now in Debian, it doens't work in ash 0.3.8-7 or bash 2.05a-11. Eitherway, I e-mailed the author and hopefully she'll write back to resolve this problem.
    I got another question regarding sh (not bash) and it's functions. I'm able to set a function but for some reason, it's not unsetting correctly.
    Code:
    $ greet() { echo "Greet Baby!!"; }
    $ greet
    Greet Baby!!
    $ set | grep greet
    _='greet'
    $ unset greet
    $ greet
    Greet Baby!!
    That's how that goes but normal variables can be unset easily with the unset command. It's the functions that are a problem.
    The best things in life are free.

  7. #6
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Well, I just read the man page for ash and it clearly states that it's NOT possible to put a single quote within a single quote. Sorry for all this nuisance.
    The best things in life are free.

  8. #7
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    BTW, what command can I use to know the current shell that I'm running?
    The best things in life are free.

  9. #8
    Linux Engineer
    Join Date
    Jan 2003
    Location
    Lebanon, pa
    Posts
    994
    echo $SHELL

  10. #9
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    That won't work if I change shells to a different shell than the default assigned by /bin/login.
    The best things in life are free.

  11. #10
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    The only thing that I've gotten close to is 'ps | grep $$'
    The best things in life are free.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •