Im trying to create an alias to open up my log fie alias open_log='date=`date +%y%m%d`;sudo tail -n 10 ~/logs/reconfig-$date.log;'When I run that alias open_logI got tail: cannot open /home/benu/logs/reconfig-.log for reading: No such file or directoryBut if I run what I set for that aliasdate=`date +%y%m%d`;sudo tail -n 10 ~/logs/reconfig-$date.log;It works perfectly fine. + service iptables saveiptables: Saving firewall rules to /etc/sysconfig/iptables: [  OK  ]+ mkdir -p /etc/nginx/sites-available+ cp /root/portal-data/sites-available/default-https /etc/nginx/sites-available/default+ '[' '!' -f /etc/ssl/mywifibusiness.trg.telenet.be.cert.pem ']'+ echo 'Error: Unable to find certificate at /etc/ssl/mywifibusiness.trg.telenet.be.cert.pem'Error: Unable to find certificate at /etc/ssl/mywifibusiness.trg.telenet.be.cert.pem+ exit 1Error: Executing /home/benu/reconfig.d/70-ssc-portal.sh returned 1Reconfigure abortedWhy theyre behaving different ? Can anyone elaborate ? How do I fix my alias to make it work ?
Why alias behave different than running bash command directly?
bash;alias
Sorry, @ihue. I got this wrong to start. Kudos to @ilkkachu.Compare the alias with the command line, posted before the edit:alias 'date=date +%y%m%d;sudo tail -n 10 ~/logs/reconfig-$date.log;'date=`date +%y%m%d`;sudo tail -n 10 ~/logs/reconfig-$date.log;The alias is missing the backticks. Also, the backticks are all but antiquated. Use the following form for command substitution: $(command).Double quotes work as follows, which sets the date each time the alias was set.alias open_log=sudo tail -n 10 ~/logs/reconfig-$(date +%y%m%d).logSingle quotes work dynamically, setting the date each time you call the alias.alias open_log='sudo tail -n 10 ~/logs/reconfig-$(date +%y%m%d).log'