Writing a heredoc to a file in a script

0 votes

How can I write a here document to a file in a script?

May 20, 2019 in Linux Administration by Upasana
• 8,620 points
1,539 views

1 answer to this question.

0 votes

try to use tee:

tee newfile <<EOF
line 1
line 2
line 3
EOF

It's concise and can be combined with sudo if you need to write to files with root permissions.

answered May 20, 2019 by Shubham
• 13,490 points

Related Questions In Linux Administration

0 votes
2 answers

How do I use a shell script to SSH in to a remote machine to execute commands?

Sorry in advance for any formatting. Check out ...READ MORE

answered Feb 7, 2021 in Linux Administration by anonymous
17,306 views
0 votes
1 answer

How to check permissions of a file in the Linux system?

Hi@akhtar, If you prefer using the command line, ...READ MORE

answered Aug 13, 2020 in Linux Administration by MD
• 95,460 points
1,745 views
0 votes
1 answer

How to find the first field from a file in Bash Shell?

Hi@akhtar, You can extract text from a file. ...READ MORE

answered Oct 20, 2020 in Linux Administration by MD
• 95,460 points
1,075 views
0 votes
0 answers

How to create a file in Linux from terminal window?

What's the easiest way to create a ...READ MORE

Apr 13, 2022 in Linux Administration by Rahul
• 9,680 points
572 views
0 votes
1 answer
+1 vote
3 answers
0 votes
1 answer

Make a unix alias with python script

The scope of an alias command is the shell ...READ MORE

answered Sep 10, 2018 in Python by Priyaj
• 58,020 points
880 views
0 votes
1 answer

Script file name in a Bash script

$0 will give you the complete basename. ...READ MORE

answered Jun 20, 2019 in Linux Administration by Shubham
• 13,490 points
762 views
0 votes
1 answer

How to extract file base name without path and extension in bash?

You don't actually have to call the ...READ MORE

answered May 31, 2019 in Linux Administration by Shubham
• 13,490 points
5,917 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP