Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- bytes="4c 56 4d 32 20 30 30 31"
- str=""
- for b in $bytes; do
- hex=$(echo "$b" | tr "[:lower:]" "[:upper:]")
- dec=$(echo "ibase=16; $hex" | bc)
- ch=$(eval "printf \$'\\x${hex}'")
- str="${str}${ch}"
- done
- echo "Data to write:"
- echo -n "$str" | hexdump -C
- # 00000000 4c 56 4d 32 20 30 30 31 |LVM2 001|
- # 00000008
- echo "Before:"
- dd if=/dev/md2 bs=1 count=8 skip=536 2>/dev/null | hexdump -C
- # 00000000 00 00 00 00 00 00 00 00 |........|
- # 00000008
- echo "Writing..."
- echo -n "$str" | dd of=/dev/md2 bs=1 count=8 seek=536
- echo "After:"
- dd if=/dev/md2 bs=1 count=8 skip=536 2>/dev/null | hexdump -C
- # 00000000 4c 56 4d 32 20 30 30 31 |LVM2 001|
- # 00000008
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement