我必须创建一个目录,包含10个字典文件,从0到9,使用文件中的单词,就像这样: 在我的文件中,例如:
012
032
..
943
234
978
我必须在文件0中:
012
032
file 2: 234
..
file 9: 978
943
(one word per line)
我试过了:
file=$1
mkdir dictionary
cat $file | while read line;do
for i in {0..9};do
var=$( echo $line | head -c 1 ) #trying to get fist character
cd dictionary
if [ "$var" -eq "$i" ]
then
if [ -e $i ] #checking if file exists
then
$line > $i
else
touch $i
$line > $i
fi
fi
done
cd ..
done
你能告诉我什么是错的吗?