1

What should commands echo [:space:] and echo [:alpha:] print on bash terminal? The behavior seems pretty random.

Sometimes it just prints the whole strings [:space:] or [:alpha:], at other times they expand to some (but not all) single character file names in the directory.

Lavya
  • 1,545
  • 5
  • 18
  • 26
  • 1
    Sounds a bit like https://unix.stackexchange.com/q/347950/117549 to me – Jeff Schaller May 05 '20 at 17:12
  • thanks. checking it out – Lavya May 05 '20 at 17:16
  • 1
    Are you sure that you typed the command into the question properly? – ctrl-alt-delor May 05 '20 at 17:47
  • @ctrl-alt-delor yes. and the behavior is very inconsistent. echo [:space:] prints a and s and echo [:alpha:] prints a. I have files a s and t in the directory, among other multi character name files. – Lavya May 05 '20 at 18:16
  • The linked question doesn't answer my question completely – Lavya May 05 '20 at 18:16
  • 1
    `echo [:space:]` will output the names of any files whose names are the single character `:`, `s`, `p`, `a`, `c`, or `e`. More interesting is `echo [[:space:]]`, which will output the names of files whose names consist of a single character of whitespace in your locale (typically, tab, LF, VT, FF, CR, or space.). – Mark Plotnick May 05 '20 at 21:13
  • 1
    Does it always do the same thing? – ctrl-alt-delor May 05 '20 at 21:40
  • @MarkPlotnick yes just realized that! thanks! – Lavya May 06 '20 at 04:49
  • @ctrl-alt-delor I typed what I was trying on my computer. But I get it now it's doing what it's supposed to do. for the glob expansion I should have used [[..]] instead of [..] which will just use the characters inside. Thanks! – Lavya May 06 '20 at 04:51

0 Answers0