Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write multilines to a file with fish?

Tags:

cat

fish

In bash, I can do:

cat >a.txt <<EOF
line 1111
line 2222
EOF

But this is invalid syntax when using in fish. What's the correct way to do it?

like image 338
Freewind Avatar asked Dec 10 '22 18:12

Freewind


2 Answers

You can use echo and a multiline string (adapted from this thread in the fish issue tracker)

echo >a.txt "\
line 1111
line 2222"
like image 76
jaimeMF Avatar answered Mar 12 '23 10:03

jaimeMF


FWIW in the console/terminal I have always used:

cat > a.txt
line 1111
line 2222
Ctrl+D

It worked both in Bash and Fish.

like image 22
martin-g Avatar answered Mar 12 '23 10:03

martin-g