when i run this command..
tail -10 /var/log/httpd/error_log | tr "\n" "----"
tr replaces new lines with nothing rather than the indent of
----
i am using tr because perhaps it might be faster than sed.
but if there are no solutions.. i wouldn't mind using sed.
ultimately i am trying to replace new lines with
</br>
tr
takes 2 sets of characters as arguments and replaces each occurence of the 1st set by the matching occurence on the 2nd set. For instance,tr "abc" "xyz"
will replace a with x, b with y and c with z. Thus it wont be able to do the job in your case as you want to replace 1 character with several – Aserre Jun 12 '14 at 8:07sed ':a; N; s/\n/<\/br>/g; $!ba;' yourfile
– sat Jun 12 '14 at 8:09tail -10 /var/log/httpd/error_log | sed -e ':a; N; s/\n/\<\/br\>/'
– stanleyxu2005 Jun 12 '14 at 8:12tr
. Since you mentioned that you can usesed
, it already has answers. – devnull Jun 12 '14 at 9:45