I've got a script that writes to a file, like so:
cat >myfile <<EOF
some lines
and more lines
EOF
but I'm not sure whether this is a Useless Use of Cat or not...
I've got a script that writes to a file, like so:
cat >myfile <<EOF
some lines
and more lines
EOF
but I'm not sure whether this is a Useless Use of Cat or not...
Even if this may not be a UUOC, it might be useful to use tee
instead:
tee myfile <<EOF
some lines
and more lines
EOF
It's more concise, plus unlike the redirect operator it can be combined with sudo
if you need to write to files with root permissions.
It is not really a UUOC. You can also do the same with echo:
echo "this is line
this is another line
this is the last line" > somefile
In zsh it is a UUOC because:
>myfile <<EOF
some lines
and more lines
EOF
Works fine.