Daily Archives: 13'-03:00'-03:00 November'-03:00 2019

Replace text/string/chars in multiple files in a folder

To identify text/strings in multiple files and replace them in multiple files simultaneously use the following command:

~$ find ./ -type f -exec sed -i 's/text/text2/g' {} ;

Note that the path of the files is determined in the second block in: ./

The searched and replaced text will be placed in place of the word: text

The text to be added in place will be placed in place of the word: text2

Remember to preserve all other attributes of the command by observing the position of quotation marks, bars, etc.

Picking up information from the USB port

With the lsusb command you will see the path to the device:

~$ lsusb

Bus 00x Device 00y: ID ……………….

By adding the attributes to the command you will have detailed information:

~$ lsusb -v -s 00x:00y

Bus 001 Device 005: ID 22b8:2e83 Motorola PCS 
 Device Descriptor:
   bLength 18
   bDescriptorType 1
   2.00 bcdUSB
   bDeviceClass 0 (Defined at Interface level)
   bDeviceSubClass 0 
   bDeviceProtocol 0 
   bMaxPacketSize0 64
   idVendor 0x22b8 Motorola PCS
   idProduct 0x2e83 
   ff.ff bcdDevice
   motorola iManufacturer 1
   motog3 iProduct 2
   iSerial 3 0016903665
   bNumConfigurations 1
   Configuration Descriptor:
     bLength 9
     bDescriptorType 2
     totallength 39 w
     bNumInterfaces 1
     bConfigurationValue 1
     iConfiguration 0 
     bm 0x80 Attributes
       (Bus Powered)
     MaxPower 500mA
     Descriptor Interface:
       bLength 9
       bDescriptorType 4
       bInterfaceNumber 0
       bAlternateSetting 0
       bNumEndpoints 3
       bInterfaceClass 6 Imaging
       bInterfaceSubClass 1 Still Image Capture
       bInterfaceProtocol 1 Picture Transfer Protocol (PIMA 15470)
       iInterface 5 PTP
       Endpoint Descriptor:
         bLength 7
         bDescriptorType 5
         bEndpointAddress 0x81 EP 1 IN
         bmAttributes 2
           Transfer Type Bulk
           Synch Type None
           Usage Type Data
         wMaxPacketSize 0x0200 1x 512 bytes
         bInterval 0
       Endpoint Descriptor:
         bLength 7
         bDescriptorType 5
         bEndpointAddress 0x01 EP 1 OUT
         bmAttributes 2
           Transfer Type Bulk
           Synch Type None
           Usage Type Data
         wMaxPacketSize 0x0200 1x 512 bytes
         bInterval 0
       Endpoint Descriptor:
         bLength 7
         bDescriptorType 5
         bEndpointAddress 0x82 EP 2 IN
         bmAttributes 3
           Transfer Type Interrupt
           Synch Type None
           Usage Type Data
         wMaxPacketSize 0x001c 1x 28 bytes
         bInterval 6
 Device Qualifier (for other device speed):
   bLength 10
   bDescriptorType 6
   2.00 bcdUSB
   bDeviceClass 0 (Defined at Interface level)
   bDeviceSubClass 0 
   bDeviceProtocol 0 
   bMaxPacketSize0 64
   bNumConfigurations 1
 Device Status: 0x0000
   (Bus Powered)

For example, you will see the maximum current (amperage/energy) on the door, remembering that the voltage is 5 volts by default. Information relevant to validate whether the port supports a device.