有這樣的腳本:如何 n識別在bash
#! /bin/bash
typeset -i i END
let END=500 i=1
remainder=1
accum="use yola_test;\n"
for ((i=1;i<=END;++i)); do
# str1=$(echo "$i" | md5sum | md5sum)
title="title_$i"
# "${str1:2:20}"
accum="${accum}CALL add_new_enterprise(\"$title\");\n"
let "remainder=$i % 100"
if [ $remainder -eq 0 ]; then
accum="${accum}SELECT count(*) as \`enterprises:\` FROM enterprise;\n"
mysql --host=l --port=0 --user=r --password='!' --execute="$accum"
accum="use yola_test;\n"
fi
done
但是,每\ n它給了我「尋呼機組到標準輸出」,我能避免這個,我知道,呼應時,我必須用-e選項,但我讀了一些關於ANSI-C引用的材料,但沒有例子如何使用它。
我試圖這樣做
mysql --host=l --port=0 --user=r --password='!' --execute="$(echo -e "$accum")"
,但它未效應,我想呼籲的回聲會增加運行時間。
,然後我做「echo -e $ accum」在輸出中沒有換行(( – Yola
)試試echo -e「$ accum」' - 雙引號是必要的,以防止外殼轉換換行符(和製表符和...)轉換爲單詞分隔,然後「回聲」變成空格。 –