(echo n; echo p; echo 1; echo 1; echo; echo wq) | fdisk /dev/sdb
The above would make a new partition 1 on /dev/sdb and save the changes to disk, you can of course make changes to do almost anything in fdisk.
fdisk, linux, bash, echo, wq, dev, sdb, partition, disk,