Script to mount exfat drive hope you are doing great.
I´m using a Macbook pro 2019 with Big Sur and I have all my photos and videos in a external drive formatted in ExFat.
Each time I have to mount the disk I need to run this steps
sudo pkill -f fsck
diskutil list
sudo umount /dev/disk2s1
sudo mkdir -p /Volumes/disk2s1
sudo mount_exfat /dev/disk2s1 /Volumes/disk2s1

Up to this point, no biggie, is a little tedoius so I wanted to create a script to do this.
My main question here is:
When I do diskutil list disk can be mounted on /dev/disk2s1 or /dev/disk3s1
nachogon@Morrowind ~ % diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         250.7 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +250.7 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD - Data     12.3 GB    disk1s1
   2:                APFS Volume Preboot                 593.1 MB   disk1s2
   3:                APFS Volume Recovery                1.2 GB     disk1s3
   4:                APFS Volume VM                      2.1 GB     disk1s4
   5:                APFS Volume Macintosh HD - Datos    147.4 GB   disk1s5
   6:                APFS Volume Macintosh HD            19.4 GB    disk1s7
   7:              APFS Snapshot com.apple.os.update-... 19.4 GB    disk1s7s1

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *4.0 TB     disk2
   1:       Microsoft Basic Data Elements                4.0 TB     disk2s1

Is there any way to grep the diskutil so I can find the disk by name (Elements) so I can assign a variable to the disk identifier
Thanks in advance for any help.
Assuming there is only one drive called Elements, running
diskutil list 'Elements' | sed -nE '/ Elements /s/.* (disk[0-9]+s[0-9]+)$/\1/p'

will return the device identifier.
Within a script you could use
disk=$(diskutil list 'Elements' | sed -nE '/ Elements /s/.* (disk[0-9]+s[0-9]+)$/\1/p'
)
if [[ -n &quot;$disk&quot; ]]; then
    mkdir -p /Volumes/Elements
    mount_exfat &quot;/dev/$disk&quot; /Volumes/Elements
fi