This is my first post here. I have only dabbled in python on Udemy and I know some HTML and CSS but decided to give BASH a go tonight. I am trying to write a simple script using a variable and it is not working. The script should print some text, ask for some user input, then use that input in a subsequent command like so:
#!bin/bash
echo "Please select a name for your new file (files are saved in txt by default)": && read $file
echo "Creating file "$file".txt on /home/linux/Desktop"
touch "/home/linux/Desktop/"$file".txt"
echo "Your new file has been created."
sleep 2
exit
the result is a hidden file which I must find in the terminal with the ls -l command and requires double quotes to remove (rm ".txt").
How do I need to write my code so that the user can name the file, the computer can recall that variable name, insert that variable name into a filepath and the touch command can utilize it to create the file?