我想写一个bash脚本打印命令。但为了便于阅读,我不希望它打印回显命令。不幸的是,我无法找到我的bash脚本的正确设置来实现此目的。我需要帮助?Bash脚本打印命令,但不打印回显命令
#!/bin/bash
# Makes the bash script to print out every command before it is executed
set -v
echo "Cleaning test database"
RAILS_ENV=test bundle exec rake db:drop
echo "************************************************************"
echo ""
echo "Setting up the test database"
RAILS_ENV=test bundle exec rake db:setup
echo "************************************************************"
echo ""
输出看起来像:
echo "Cleaning test database"
Cleaning test database
RAILS_ENV=test bundle exec rake db:drop
echo "************************************************************"
************************************************************
echo ""
echo "Setting up the test database"
Setting up the test database
RAILS_ENV=test bundle exec rake db:setup
正如你可以看到它打印出所有包含echo命令,这是我不想看到的命令。
你有什么想法吗?
干杯,
赫拉尔
也许这吗?:'| | grep -v“echo”' – whoan
Makefile适合你的任务吗?这是一种截然不同的方法,但是'make'会在执行时默认回应每个命令,*除非*前缀为@。 – chepner