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*

3
  • This is a minor variant on unix.stackexchange.com/q/14684/5132 . Commented May 20, 2019 at 12:33
  • Print the string to the terminal and then copy it back from terminal to your string. Commented Mar 12, 2024 at 16:15
  • You can also use tr command to delete everything except the class of characters you want. For example to keep only alphanumeric characters and get rid of everything else: echo $a | tr -dc '[a-zA-Z-0-9]' Commented Mar 12, 2024 at 16:19