Comments on: 16 Quick Cat Command Examples in Linux https://www.linuxtechi.com/cat-command-examples-for-beginners-in-linux/ Thu, 14 Jan 2021 16:01:16 +0000 hourly 1 By: danny https://www.linuxtechi.com/cat-command-examples-for-beginners-in-linux/#comment-277 Thu, 05 Jan 2017 14:55:19 +0000 http://www.linuxtechi.com/?p=3116#comment-277 how do you modify the cat command to show only the last paragraph of a textfile

]]>
By: Someone https://www.linuxtechi.com/cat-command-examples-for-beginners-in-linux/#comment-276 Wed, 27 May 2015 03:07:25 +0000 http://www.linuxtechi.com/?p=3116#comment-276 In reply to Parijatha Kumar.

Did you try
su -c ‘cat hosts >> /etc/hosts’

]]>
By: Kim Mik https://www.linuxtechi.com/cat-command-examples-for-beginners-in-linux/#comment-275 Tue, 26 May 2015 15:48:33 +0000 http://www.linuxtechi.com/?p=3116#comment-275 In reply to Parijatha Kumar.

You can do the following:

cat hosts | sudo tee /etc/hosts

tee (which is executed with sudo rights) will write the output to /etc/hosts and print it to standard out.

]]>
By: Me https://www.linuxtechi.com/cat-command-examples-for-beginners-in-linux/#comment-274 Tue, 26 May 2015 15:31:45 +0000 http://www.linuxtechi.com/?p=3116#comment-274 In reply to Parijatha Kumar.

@Kumar

Do
$ cat hosts | sudo tee /etc/hosts

]]>
By: David https://www.linuxtechi.com/cat-command-examples-for-beginners-in-linux/#comment-273 Tue, 19 May 2015 16:20:17 +0000 http://www.linuxtechi.com/?p=3116#comment-273 Be careful, Examples 4 and 11 are winners of the “Useless use of cat award,” which is often the case when you pipe cat output to another command.

]]>
By: Parijatha Kumar https://www.linuxtechi.com/cat-command-examples-for-beginners-in-linux/#comment-272 Tue, 19 May 2015 13:19:52 +0000 http://www.linuxtechi.com/?p=3116#comment-272 The following command does not work.
sudo cat hosts >> /etc/hosts.
That’s why. I do …
1) sudo su
2) cat hosts >> /etc/hosts
Is there a single command to achieve the result of the above two commands ?

]]>