help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Simplest way to keep trailing newlines when reading a file i


From: Peng Yu
Subject: [Help-bash] Simplest way to keep trailing newlines when reading a file into a bash variable
Date: Sat, 19 May 2018 05:04:52 -0500

On the following thread, it discusses many ways to keep trailing
newlines in command substitution. But all the solutions require some
extra code that is not very convenient.

https://unix.stackexchange.com/questions/383217/

It is simple to read a file with training newlines removed into a bash variable.

x=$(< file)

Supposedly, it should be reasonable to expect a solution with as
little code as possible (e.g., no intermediate variable, one line).
But I haven't found such a solution. Does anybody know such a simplest
solution? Thanks.

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]