I have a file log.txt
with this content:
systemd[1]: Starting dracut cmdline hook...\r\n[ 8.759274] systemd[1]:
When I do cat log.txt
output is:
systemd[1]: Starting dracut cmdline hook...\r\n[ 8.759274] systemd[1]:
Expected output is 2 lines (\r\n
to be replaced with visibly new line):
systemd[1]: Starting dracut cmdline hook...
[ 8.759274] systemd[1]:
How to achieve this in a bash terminal?
Without involving any external command, you can do this using printf '%b\n'
instead of cat
:
printf '%b\n' "$(<log.txt)"
systemd[1]: Starting dracut cmdline hook...
[ 8.759274] systemd[1]:
%b
expands backslash escape sequences in the corresponding argument$(<log.txt)
is bash directive to get content of log.txt
You can use echo -e
for that:
echo -e $(<log.txt)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With