Unusual characters in Brace expansion of characters in bash

I was generating random characters for some purpose. By mistake I try the following in a terminal and got some surprising result. I am using bash shell provided by Ubuntu.

$ echo {Z..a}
Z [ ] ^ _ ` a

Inspiring by this result, I did

$ echo {z..A}
z y x w v u t s r q p o n m l k j i h g f e d c b a ` _ ^ ] [ Z Y X W V U T S R Q P O N M L K J I H G F E D C B A

My question is what are these five characters [ ] ^ _ ` doing in the range. Do they have any special meaning or I am just performing some forbidden action.

People usually use $ echo {{A..Z},{a..z}} in order to get both lower as well as the upper case characters,

1 Answer

Take a look at ascii table. After uppercase Z there are exactly those characters that you got, so there's no surprise - bash read ascii table from where you told it to, to where you told it to. \ does not show up, though, because it is usually used for escape sequences like \n - a newline

enter image description here

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like