osx - how to use grep command to get infromation of particular device on mac -


im running mac , wanted find vendor id, product id, serial number , if possible mount volume of pendrive. , ended system_profiler spusbdatatype, displays whole bunch of list of various devices paragraphs,.. looking forward details(vendor id, product id, serial number) of pendrive. tried grep, either 1 of detail able get. command gave

$ system_profiler spusbdatatype | grep -i "vendor id:"

what should grep command (preferably single line command) information of particular device.

grep line-oriented; no, cannot paragraph-oriented operations in general. turn awk, excellent type of task.

without access sample output, speculative, like

system_profiler spusbdatatype | awk '/this drive want/ { p=1 }   /vendor id|product id|serial number/ && p   /^$/ { p=0 }' 

this assuming regular expression this drive want matches first line of output particular drive interested in, , output individual drives separated empty lines (the regular expression ^$ matches that). variable p true between 2 lines; print when see match on middlemost regular expression.


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -