脚本奇怪的行为与最后的&符号

时间:2015-08-17 08:25:31

标签: bash shell

我正在编写一个脚本,我面临一个非常奇怪的问题。 我的剧本是:

#!/bin/bash
set -x
cd /scripts/my-scripts
echo "Getting data from database."
mysql -N -umyuser -pmypass -hdb.test.example.com  COLLEGE -e"select distinct id as myid from candidate_info where name = 'john' and id is not null  " > test_skus &
echo "DONE"
echo `wc -l test_skus`

它将0作为字数。但如果我删除&在此结束时:

mysql -N -umyuser -pmypass -hdb.test.example.com  COLLEGE -e"select distinct id as myid from candidate_info where name = 'john' and id is not null  " > test_skus &

它给出了结果。可能是什么原因?请帮忙

0 个答案:

没有答案