Forrest logo
back to the tr tool

file_manipulation:warp:42e78

Replace newline with a space in a file
$ tr '\n' ' ' < ${file_name}
try on your machine

The command "tr" is used in Unix-like operating systems to translate or delete characters. In this case, the command is used to translate newline characters ('\n') into space characters (' ') within the given file.

The "<" symbol is used for input redirection, specifying that the input should come from the file specified by the variable "file_name".

So, the command takes the contents of the file, replaces newline characters with spaces, and outputs the modified content to the console.

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.
back to the tr tool