I am trying to run a command example:
sudo mv /home/vaishnavi/Downloads/*.ttc /home/vaishnavi/Downloads/*.ttf /usr/local/share/fonts/ms_fonts/
It works fine in the terminal, but when I try to add this in a shell script (.sh
) I get an error saying:
mv: cannot stat '/home/vaishnavi/Downloads/*.ttf': No such file or directory
Simply, I want to move all the files of .ttf
and .ttc
type to /usr/local/share/fonts/ms_fonts/
, in this case. Frankly speaking, I am not so expert in shell scripts. Please explain to me what wrong I did and also an alternative to achieve my expected results.
My sample script:
sudo mv /home/vaishnavi/Downloads/*.ttc /home/vaishnavi/Downloads/*.ttf /usr/local/share/fonts/ms_fonts/
...
exit 0
You'll get this error if there are no *.ttf files there. By default, if no files match a glob pattern, then the pattern itself remains in the command. Turn this off with the bash
nullglob
shell optionTo be a bit safer, verify there are actually some files to move: