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,530 points
33 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 by Shubham
• 13,290 points

Related Questions In Linux Administration

0 votes
1 answer
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,290 points
79 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,290 points
27 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,290 points
55 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,520 points
24 views
0 votes
1 answer

Script file name in a Bash script

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

answered Jun 20 in Linux Administration by Shubham
• 13,290 points
14 views
0 votes
1 answer