Hi All,
I am new to scripting and wondering why grep is resulting in incorrect result when i am trying to find a word from a piped result.
]# fdisk -l
Disk /dev/sda: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 783 6185025 8e Linux LVM
Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 3916 31455238+ 83 Linux
Disk /dev/sdc: 268 MB, 268435456 bytes
64 heads, 32 sectors/track, 256 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd: 268 MB, 268435456 bytes
64 heads, 32 sectors/track, 256 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk /dev/sdd doesn't contain a valid partition table
]#
and ran be below command to fetch the line which contain "sdb"
[root@LRC109-RNC2-3GOAM-0 ~]# fdisk -l | grep sdb
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd doesn't contain a valid partition table
Disk /dev/sdb: 32.2 GB, 32212254720 bytes
/dev/sdb1 * 1 3916 31455238+ 83 Linux
[root@LRC109-RNC2-3GOAM-0 ~]#
I need only the line with "sdb" but grep is throwing a different result.
I need to include similar kind of stuff in a shell script to deal with some devices information
Please help me in this regards.