![Forrest logo](/images/logo.png)
tr:tldr:1645b
tr: Strip out non-printable characters from a file.
$ tr -cd "[:print:]" < ${filename}
try on your machine
This command uses the tr
command to delete any characters that are not printable from the contents of a file.
Here is the breakdown of the command:
tr
: This is the command for translating or deleting characters.-cd
: These are the options of thetr
command. The-c
option stands for "complement," which means it selects characters not in the specified set. The-d
option stands for "delete," which means it deletes the selected characters."[:print:]"
: This is the set of characters specified for selection.[:print:]
specifies all printable characters.< ${filename}
: This redirects the contents of the file${filename}
as input to thetr
command.
So, this command reads the content of the specified file (${filename}
), removes all characters that are not printable, and outputs the result to the standard output.
This explanation was created by an AI. In most cases those are correct. But please always be careful and
never run a command you are not sure if it is safe.