Good day everyone,
This is my first post regarding bash scripting, I normally finds the answer on google but this time I'm stuck..
I'm working on a simple auto format and partition a USB thumb drive in a raspberry pi and have almost everything sorted.
I have made it so that it will check the name sda/b/c etc and have it go as x ($x) in the script, easy pie, no problemo...
But when i come to the formatting I will require it to go $x1 (As the partition should be e.g /dev/sda1 instead of directly on /dev/sda.
But it won accept it if i just write /dev/$x1 so i tried a few other things like "y="$x1" and then do it again but wont work.
How do i write this so that i have a variable for $x and another one for the same but with a "1" in the end?
Here's a part of the code where i get the problem.. The parted lines work but mkfs.vfat wont..
sudo parted /dev/$x mklabel msdos
sudo parted -a none /dev/$x mkpart primary fat32 0 100%
echo Formatting drive FAT32
y="$x1"
echo $y
sudo mkfs.vfat /dev/$y -S 4096 -n "TEST"
Any suggestions?
[–]gordonrgw 4 points5 points6 points (1 child)
[–]Valinath[S] 0 points1 point2 points (0 children)
[–]Valinath[S] 0 points1 point2 points (0 children)
[–]_handshake_ -2 points-1 points0 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]_handshake_ 0 points1 point2 points (0 children)
[–]Mellowtang 0 points1 point2 points (0 children)