using:
neofetch --stdout |grep 'OS:'
OS: Kubuntu 22.04.3 LTS x86_64
dd --version
dd (coreutils) 8.32
Background:
- re-purpose a disk = objective
- some script is being developed
- some script will delete first 128 MB of disk:
ddurandom,ddzero - some script will delete last 128 MB of disk:
ddurandom,ddzero - command below shows terminal status of disk first 1024 bytes
- command below shows terminal status of disk last 1024 bytes
- sudo wxHexEditor -- confirms terminal output
Question:
How to tell dd to limit screen output to 90 characters wide?
1024 characters wide is the block of data
_111 characters was screen width
__90 characters is desired output width.
Why 90 characters wide for Terminal output?
Because 90 characters wide matches screen of wxHexEditor 0.24
script and function:
d2d=sd_ # sda or sdb or sdc ... d2d=disk2display or disk2delete
num1=1 # used twice in function below ...
clear
function105_firstbytes_lastbytes(){
tput setaf 8
sudo dd if=/dev/$d2d bs=512 count=1 skip=0 status=none |hexdump -ve '1/1 "%.2x"' #First_bytes
echo
tput setaf 12
echo " above First bytes, Below Last bytes" ;
tput setaf 8
sudo dd if=/dev/$d2d bs=512 count=$num1 skip=$(($(sudo blockdev --getsz "/dev/$d2d" ) -$num1)) status=none |hexdump -ve '1/1 "%.2x"' #Last_bytes
}
function105_firstbytes_lastbytes #call_above_function
The current output = 111 characters wide.
The desired output = _90 characters wide.
The desired output would look like, see below:
fab800108ed0bc00b0b800008ed88ec0fbbe007cbf0006b90002f3a4ea21060000bebe073804750b83c61081aa
fe0775f3eb16b402b001bb007cb2808a74018b4c02cd13ea007c0000ebfe000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000003a17e5ab0000007f0280
83fec2ffffff00001af1e50e000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000055aa
above First bytes, Below Last bytes
ddf5454fc7754665c43e2dc420c4edf6a5096e490bf3efdd00259d5712e2c73250916c64f822874eb5db155b77
371ab1bcd1e60a2331b4df1f2b64b49ed8270236481a79f4c48b7c9f04bf8acc8dcd7ba80a2f8052da27e1d400
7edea887cc579848edbb87ef260fee4a8e2424e706a475f6e565f010dd07de053bcaed7f4c449365d3b0d8906e
fa10e4cb9263bb3065ef9862db4ca7ba3d03e0835edc8865474ef088390a68ca67daf7ce57215e02d9e90e6042
d2ef66c1290fc55730e076645c55ffc7c15fdae24678a6a6fdb69ab66c0299a4d2e1dd342f1e25ee3277634080
ceb7b5068633592ec5d061cbf0cac42d02511362393d49c5d6c7b056843881fa634a1036cef09603c60caea6cc
da0373467f929e9fd358adf8e4aa5502b4847b2d9f1589c4de13adeaac7dedce9963b9e0740ee6938d62c1352a
4e80244446b85d43ef9e5e9180cfe15f3f1ccc035ef2be506e5bb9114791ef81b7930a2871b22b4cb91a5a1c3e
d90816f5e701e4ac33023a38989caa0231ba84571cccff2ded5c0ab14556b6685e813724167feb6f7eae760fea
61dacd2902dd92695af3c9c35a574e2b9f471d9a64e6589ce44406ab96f4faf1161cb5431c3ef35c61a02b33ca
ed1200a35c765504362dcf2bae73ca7be2f34fcc55da77005f802a7af28932c2ca2d78b846db4370edeea8b859
1d3501933c4062f9acd5ddc8e31223edf3
.
sidebar Question:
Why does dd command bs=512 output 1024 bytes?
Why double? 512 x 2 = 1024 bytes
from man dd
bs=BYTES -- read and write up to BYTES bytes at a time
(default: 512); overrides ibs and obs
sidebar Answer:
Why 892 bytes altered not 446 bytes? 446x2=892 bytes
Why 892 bytes altered not 446 bytes? 446x2=892 bytes
showing 8 bits (i.e. a single byte) in
hexadecimal format requires 2 characters – Jaromanda
.
What command to force dd output to a
fixed width of 90 characters?
--