Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 8
    In bash and zsh this can be done without the loop and without the external command: printf $(printf '\%o' {32..127}). Commented Aug 4, 2012 at 12:02
  • @manatwork: ya exactly..thanks a lot for pointing it out.. Commented Aug 4, 2012 at 12:08
  • 1
    @pradeepchhetri : Thank you for the detailed response and it seemed to cover most of the required details (hence I choose your answer). However I guess it missed out an important piece of information which can be found in the following message at unix.derkeiler.com/Newsgroups/comp.unix.shell/2007-07/…. It states that "The argument operands shall be treated as strings if the corresponding conversion specifier is b, c, or s..." Commented Aug 4, 2012 at 18:11
  • Isn't (char)(127) backspace or something like that. Whatever it is, it appears as one of the hex-boxes or whatever they are called. If you want only the "printable" (i.e. readable), just go to 126. Also, nice thought with the octal. That's clever; I was thinking in terms of hexadecimal (like printf '\x%x; {32..126} ... or 127, I guess, since all of you did it, too), but it doesn't work. Octal saves the day! :) Finally, @Ifthikhan, I'm not sure what you mean. awk often uses C-style commands and nowhere else is %c used. Using octal numbers is different than using one-byte characters. Commented Nov 20, 2014 at 14:31