Asked • 04/25/19

How does "cat << EOF" work in bash?

I needed to write a script to enter multi-line input to a program (`psql`). After a bit of googling, I found the following syntax works: cat << EOF | psql ---params BEGIN; `pg_dump ----something` update table .... statement ...; END; EOF This correctly constructs the multi-line string (from `BEGIN;` to `END;`, inclusive) and pipes it as an input to `psql`. But I have no idea how/why it works, can some one please explain? I'm referring mainly to `cat << EOF`, I know `>` outputs to a file, `>>` appends to a file, `<` reads input from file. What does `<<` exactly do? And is there a man page for it?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.