سؤال

I have this command line

$ sudo find /etc/grub.d | sort | tail -n 1 | xargs sudo cat | wc

that I want to execute with a single sudo command

$ sudo --some-how "find /etc/grub.d | sort | tail -n 1 | xargs cat | wc"

such that the entire command line is run as root.

هل كانت مفيدة؟

المحلول

Try this:

$ sudo sh -c "find /etc/grub.d | sort | tail -n 1 | xargs cat | wc"

نصائح أخرى

This is the best I can do so far, but I am hoping for something less hack-like

$ echo "find /etc/grub.d | sort | tail -n 1 | xargs cat | wc ; exit" | sudo -iE
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top