title: How to find the serial number of removable devices using C program
body: <p>I am using the bash script to get the serial number of the removable device like pen drive for my another application.
  Is it possible to do in native C can someone convert this bash to C. </p>
  
  <pre><code>#!/bin/bash
  for C in `ls /sys/block/`; do 
      RE=`cat /sys/block/$C/removable`
          if [ $RE == "1" ] ;then 
              #VENDOR=`/bin/udevadm info --name=/dev/$C | grep ID_VENDOR=|awk -F"=" ' { print $2}'`
              #MODEL=`/bin/udevadm info --name=/dev/$C | grep ID_MODEL=|awk -F"=" ' { print $2}'`
              #SERIAL=`/bin/udevadm info --name=/dev/$C | grep SERIAL_SHORT|awk -F"=" ' { print $2}'`
              #echo $VENDOR-$MODEL"-"$SERIAL #print as per your taste
              USB_SERIAL=`/bin/udevadm info --name=/dev/$C | grep ID_SERIAL=|awk -F"=" ' { print $2}'|awk -F"-" ' { print $1}'`
              echo  $USB_SERIAL #or just the default one
          fi 
  done
  </code></pre>
  
  <p>I  dont want to use system calls. want pure C program</p>