I want to extract the value set to the root variable in following kernel command line, I don't want to use awk column number.
console=ttyO0,115200n8 noinitrd mem=256M root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait=1 ip=none
I am able extract it using following command but it depends on the position of root variable but if that position changes it won't work
cat /proc/cmdline | awk '{print $4}' | cut -d '=' -f2
Any suggestions/hint/pointers ?
EDIT:
All answers are correct, I am accepting Aaron's answer as he was the first to reply.
sed
works better here:
cat /proc/cmdline | sed -e 's/^.*root=//' -e 's/ .*$//'
The first expression removes root=
and everything before. The second one removes the next space and everything after.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句