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 in Linux Administration by Upasana
• 8,210 points
15 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 by Shubham
• 12,890 points

Related Questions In Linux Administration

0 votes
1 answer

How to get octal file permission in linux?

You can use this: stat -c "%a %n" ...READ MORE

answered Jan 3 in Linux Administration by Omkar
• 67,000 points
60 views
0 votes
1 answer

How to take input from user in bash script?

You can use if-else branch to check ...READ MORE

answered Jan 31 in Linux Administration by Omkar
• 67,000 points
21 views
0 votes
1 answer

How to create a symlink in Linux?

To create a symbolic link, you can ...READ MORE

answered Jan 31 in Linux Administration by Omkar
• 67,000 points
44 views
0 votes
1 answer

how to loop through the content of a file using bash

One of the ways to do it ...READ MORE

answered Feb 15 in Linux Administration by ajs3033
• 7,120 points
52 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
• 56,140 points
15 views
0 votes
1 answer

Script file name in a Bash script

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

answered 6 days ago in Linux Administration by Shubham
• 12,890 points
7 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.