Hi all, I am trying to create a script to read my Windows UUIDs and create mounts in fstab. I know there are different and maybe even better ways to mount Windows partitions at boot time, but I always manually create them in fstab successfully. I do a clean install of Ubuntu often and would like to just run a script to do it for me. I have created a script, but I can't echo a variable contents into fstab. I am semi-new at Linux scripting (been batch/dos scripting for years) so please take it easy on me when you see I've done something wrong lol. Here's my code:
#!/bin/bash
#Reads Windows partitions UUID's from blkid and creates mount in fstab
mkdir /media/Windows1
mkdir /media/Windows2
blkid /dev/sda2 | awk '{print $3}' | sed 's/,0//' > $HOME/sda1.txt
blkid /dev/sda6 | awk '{print $2}' | sed 's/,0//' > $HOME/sda2.txt
part1=$(<$HOME/sda1.txt)
part2=$(<$HOME/sda2.txt)
echo "#Windows" >> /etc/fstab
echo $part1 /media/Windows1 ntfs-3g default 0 0 >> /etc/fstab
echo $part2 /media/Windows2 ntfs-3g default 0 0 >> /etc/fstab
rm -f $HOME/sda1.txt
rm -f $HOME/sda2.txt
But in fstab all that appears is
#Windows
/media/Windows1 ntfs-3g default 0 0
/media/Windows2 ntfs-3g default 0 0
I have checked the text files and the UUIDS have been echoed into the files.
Would someone mind telling me what I am doing wrong please?