svent / sift

A fast and powerful alternative to grep
https://sift-tool.org
GNU General Public License v3.0
1.6k stars 108 forks source link

Question: Replace bash onliner with sift / golang #100

Open pwFoo opened 6 years ago

pwFoo commented 6 years ago

Could you help me to replace that bash oneliner with golang / sift? To HW detection and load needed modules during boot / initialization.

grep -h MODALIAS /sys/bus/*/devices/*/uevent | cut -d= -f2 | xargs /sbin/modprobe -abq 2> /dev/null

I'm new with golang and search a replacement

The modprobe part can be ignored.

stonedbovines commented 6 years ago

sift --no-filename --no-color MODALIAS /sys/bus/*/devices/*/uevent is the equivalent extraction

pwFoo commented 6 years ago

Thank's! Seems to be easy to include the cut command in sift.

sift '(MODALIAS=)(.*)' --no-filename --no-color --replace '$2' /sys/bus/*/devices/*/uevent

But how to remove empty lines?