[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Please check my sudo bash script



On Sun, 31 Aug 2025 09:55:04 -0500
Tom Browder <tom.browder@gmail.com> wrote:

> SDX=sda
> sudo parted /dev/${SDX} mklabel gpt
> sudo parted -a opt /dev/${SDX} mkpart primary ext4=0% 100%
> sudo mkfs.ext4 /dev/${SDX}

Two style notes:

* I would put quotes around any variable, in this case $(SDX}.

* I would use lower case, sdx. System variable are upper case so as to
  reserve lower case for user variables such as this one.

More important, you want to specify a partition number in that last
line:

sudo mkfs.ext4 /dev/"${SDX}${y}"

where $y is the partition you made in the previous line. It will
probably be 1, but I'd see if I could query parted for it.

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/


Reply to: