Find the answer to your Linux question:
Results 1 to 3 of 3
Hi there, I encountered a weird error in Linux. Here's how it went: In our 4-server environment, 3 servers are having unexpected outputs when executing an echo command for a ...
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    2

    Unhappy Need help on bracketed strings

    Hi there,

    I encountered a weird error in Linux. Here's how it went:

    In our 4-server environment, 3 servers are having unexpected outputs when executing an echo command for a bracketed string particularly with a capital letter N. Does anyone know how to fix this? We might have different settings in our 4 boxes.

    Samples:

    SERVER 1:

    >echo [N]
    [N]

    >echo [sampleNcommand]
    [sampleNcommand]


    SERVER 2-4:
    >echo [N]
    N

    >echo [sampleNcommand]
    N


    I'd really appreciate me if there's any solution to output the correct string.

    Here are the uname -a output for each server (I modified the hostnames):

    SERVER 1:
    Linux TSERVER1 2.6.9-78.0.13.ELsmp #1 SMP Wed Jan 7 17:45:52 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

    SERVER 2:
    Linux TSERVER2 2.6.9-78.0.13.ELsmp #1 SMP Wed Jan 7 17:45:52 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

    SERVER 3:
    Linux TSERVER3 2.6.9-78.0.13.ELsmp #1 SMP Wed Jan 7 17:45:52 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

    SERVER4:
    Linux TSERVER4 2.6.9-78.0.13.ELsmp #1 SMP Wed Jan 7 17:45:52 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

    Thanks a lot in advance!

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,975
    The square bracket is a single character match wildcard in the shell. If nothing matches, then echo will show then entire thing including the brackets. If there is a file or directory that matches (in your case the file or directory name would be named N) then only the matched name is echoed. For example, if you executed "echo [NTV]" and there was a file/directory named N, T, or V, then all matches would be echoed. In your case, only one letter is inside the brackets, so it would only match a file/directory named N. If you want to echo [N] always, and not match files, then you need to use backslashes before the brackets. Example "echo \[N\]". I hope this helps.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Posts
    2
    Hi Rubberman, tried looking for the N file and it's there in the three servers. Thanks a lot!

Posting Permissions

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