Comments on: How to Write/Append Multiple Lines to a File on Linux https://tecadmin.net/write-append-multiple-lines-to-file-linux/ How to guide for System Administrator's and Developers Sun, 28 Mar 2021 08:38:46 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Venkatesh https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-62402 Sun, 28 Mar 2021 08:38:46 +0000 https://tecadmin.net/?p=13508#comment-62402 HI Sir ,
I need to add multiple lines of text(22 lines ) at the beginning of a file .
I have tried the method 3 above but apending happening at the End of File .Please help me with the command.In anticipation of your reply

Thanks

]]>
By: Venkatesh https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-62401 Sun, 28 Mar 2021 08:35:49 +0000 https://tecadmin.net/?p=13508#comment-62401 I have tried the method 3 but it is append at the end of the file

]]>
By: Venkatesh https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-62400 Sun, 28 Mar 2021 08:34:56 +0000 https://tecadmin.net/?p=13508#comment-62400 Hi sir,
I need to add multiple lines of text(22 lines ) at the beginning of file.

PLease help me with the command .In anticipation of your reply

]]>
By: Nishant Jaiswal https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-52198 Fri, 26 Jun 2020 20:41:58 +0000 https://tecadmin.net/?p=13508#comment-52198 Method 3 is working for me, Thanks a lot

]]>
By: Anna https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-49672 Sat, 16 May 2020 19:39:33 +0000 https://tecadmin.net/?p=13508#comment-49672 Hello , i want to append multiple lines to sshd_config.
like below :
Match Address
PermitRootLogin without-password

It should exactly in above format ..Could you please me using sed command

]]>
By: Rahul https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-44689 Tue, 04 Feb 2020 05:52:20 +0000 https://tecadmin.net/?p=13508#comment-44689 Hi Jayesh, Use the command as following:

echo -n 'GENERICS_DOMAIN_FILE(`/etc/mail/sendmail.gdf’)' >> jayesh.txt

Using the -n will not add the trailing newline.

]]>
By: jayesh https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-44672 Mon, 03 Feb 2020 15:46:12 +0000 https://tecadmin.net/?p=13508#comment-44672 i apand to this :- echo -n GENERICS_DOMAIN_FILE(`/etc/mail/sendmail.gdf’) jayesh.txt
below error please any solution
-bash: syntax error near unexpected token `(‘

]]>
By: Rahul https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-43222 Wed, 16 Oct 2019 04:59:07 +0000 https://tecadmin.net/?p=13508#comment-43222 You can use the sed command to do this: Below example will append a string to line 4 in file.txt.

sed -i ‘4s/$/ morestring/’ file.txt

]]>
By: sanjeevi kumran https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-43197 Tue, 15 Oct 2019 07:01:12 +0000 https://tecadmin.net/?p=13508#comment-43197 I want to add a word in a specific line in the file. How can I do that? Do I need to mention the line number? Thanks in advance.

]]>
By: Jawad Kakar https://tecadmin.net/write-append-multiple-lines-to-file-linux/#comment-42598 Fri, 13 Sep 2019 13:31:30 +0000 https://tecadmin.net/?p=13508#comment-42598 Option 3 did the job!!! Thanks!

]]>