Discussion:
[bash] read text from file
Add Reply
alex
2024-12-24 10:21:33 UTC
Reply
Permalink
$ cat file.txt
aaa
bbb
ccc

OK

$ echo $(cat file.txt)
aaa bbb ccc

Why?
Lem Novantotto
2024-12-24 10:51:50 UTC
Reply
Permalink
Post by alex
$ cat file.txt
aaa
bbb
ccc
OK
$ echo $(cat file.txt)
aaa bbb ccc
Why?
'Cause you didn't quote the variable.

$ echo "$(cat file.txt)"
aaa
bbb
ccc
--
Bye, Lem
alex
2025-01-07 11:21:11 UTC
Reply
Permalink
Post by Lem Novantotto
Post by alex
$ cat file.txt
aaa
bbb
ccc
OK
$ echo $(cat file.txt)
aaa bbb ccc
Why?
'Cause you didn't quote the variable.
$ echo "$(cat file.txt)"
aaa
bbb
ccc
thanks

Loading...