I'm trying write a script which requires user interaction. Basically, the script has to ask user about 3 parameters: name of the file(s) which user wants to find, the number of days during which the file(s) were modified and the name of a tar archive. When all parameters are known script must find the appropriate files and make them into an archive with a given name. When I write a single command into the terminal:
find -name 'zad*' -mtime -10 | tar -cvf archive.tar.gz -T -
it works good. How can I use a variable entered by a user to invoke the command which is in the same script? My script is making an empty archive.
echo "Enter a number of days" read days echo "Enter the name of file" read nameoffile echo "Enter the name of tar archive" read nameofarchive find -name '"$nameoffile"' -mtime -"$days" | tar -cvf "$nameofarchive".tar.gz -T -