1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Case sensitivity in bash

Discussion in 'Linux / Unix Discussion' started by ffreeloader, Nov 23, 2005.

  1. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Taken from the Advanced Bash Scripting Guide:

    This explains why the case sensitivity is no longer a feature of the output from the "ls" command in the bash shell. So, if you want the output from "ls" to distinguish between "A" and "a" follow the instructions given above.

    Another mystery solved. I wondered why Phoenix would say bash did something I'd never seen it do, now I know. I guess Phoenix is still using an old version of bash or just hadn't noticed the difference in the newer versions as per the conversation from the thread on how Firefox collates bookmarks.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  2. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    When first learning the bash script it's hard to know just how to phrase a series of commands in which each is piped into the next command in the series. Here's a cool little tip for figuring out which one isn't working correctly. However, there is a bug in version 2.05, and possibly earlier, that may cause this to not work. However, you can get around that by upgrading to version 3 or above as I just did on my Debian machine.

    Say you have the following scenario and it's not working correctly: command1 | command2 | command3 | command4. You should get a return but the return you're getting is an empty set, or iow's the return is an empty line.

    Here's how you determine which command is failing: echo ${PIPESTATUS[*]}.

    What I do is write a small function so I don't have to do so much typing if I'm spending some time figuring out bash commands. Here it is. It's very simple and can be written from the prompt and then called by just typing the name of the function.

    pipe ()

    (

    echo ${PIPESTATUS[*]}

    )

    To call this all you do is place a semicolon (;) after your last piped command then enter "pipe" (If you name it the same as I did.).

    The syntax looks like this: command1 | command2 | command3 ; pipe .

    The output will look like the following.

    0 127 0

    0 = successful command
    127 = failed command

    P.S. When you write a function at the bash prompt such as the one above the first time you hit enter--after the line "pipe ()"--you will be taken to a prompt that looks like this ">". From there you just keep on entering your commands. After you type the closing ")" and hit enter you will be taken back to your normal bash prompt. At this point this function will be available to you until you exit bash. Once you restart bash you will have to re-enter the function.

    Anyway, I hope this helps. It's a pretty handy little troubleshooting tool for newbies such as I.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  3. simongrahamuk
    Honorary Member

    simongrahamuk Hmmmmmmm?

    6,199
    125
    199
    Great Stuff Freddy! Keep it coming! :biggrin
     
  4. tripwire45
    Honorary Member

    tripwire45 Zettabyte Poster

    13,493
    179
    287
    Freddy, I wonder if you should keep all your Bash tips in one thread so they don't get lost over time. We could pin the thread to the top of the Linux forum so people could refer to it over time. Just a thought.
     
    Certifications: A+ and Network+
  5. moominboy

    moominboy Gigabyte Poster

    excellent idea trip, as i've been saving the url's for a while now.

    and excellent work freddy for giving us these gems! :tongue
     
    Certifications: ECDL
    WIP: A+
  6. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Well, you're the one with the power around here, not me.... :twisted:
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  7. tripwire45
    Honorary Member

    tripwire45 Zettabyte Poster

    13,493
    179
    287
    I just wanted to check with you on it first. :)

    EDIT: Darn! Apparently, I don't know how to merge threads correctly. I get a lousy error message about a bad URL. Might have to wait until Gav makes the scene. :oops:
     
    Certifications: A+ and Network+
  8. Jakamoko
    Honorary Member

    Jakamoko On the move again ...

    9,915
    60
    229
    Threads merged, but as you can see it didn't come out too neatly due to all posts from both threads merging chronologically.

    Trip is right, Freddy - why not create one thread specifically for your Bash series, and we can pin it up top ? Let me know and I'll help you out and see if we can do something about tidying up this Thread (if you want) :)
     
    Certifications: MCP, A+, Network+
    WIP: Clarity
  9. Bluerinse
    Honorary Member

    Bluerinse Exabyte Poster

    8,871
    167
    256
    Nice work Freddy! I think the idea of pinning a dedicated thread is great. I am reading every word you write Freddy but I am not really ready just at the moment to start delving into bash. But when I am, this will be one of the first places I come to re-read what you have kindly provided.

    It would be nice if more posters provided their insight into the technologies they are currently learning. I am sure it would help others as well as help the poster to remember the material. There is nothing quite like putting things into your own words to consolidate the information.

    Once again, good work and keep 'em coming 8)
     
    Certifications: C&G Electronics - MCSA (W2K) MCSE (W2K)
  10. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    My thought is to start a sub forum under the Linux heading and dedicate it to bash scripting/Linux scripting/Linux programming as it's a complex enough subject to deserve its own forum. There's one for Windows scripting/programming so why not for *nix too? Then all that would need to be done is move the threads to that forum.

    It would make the individual scripts easier to find as putting everything in one thread would soon be pretty cumbersome.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1

Share This Page

Loading...