In this line:
tr a A < /etc/hosts | sort -r |pr -d > /etc/hosts
what would be the expected outcome? I know lowercase 'a' would change to uppercase 'A' but what's next? Would the original file be overwritten since the redirect is to the same file name?
bash: /etc/hosts: Permission denied
error (assuming your shell is bash), unless you're running this asroot
./etc/hosts
is normally writable by root only. Iff you're running this asroot
(which you really shouldn't), you'd get an empty/etc/hosts
as Michael Homer explained. – arielf Feb 26 '18 at 18:39