huangyingw
April 17th, 2009, 03:34 PM
hello,
I have difficultity at debuging the shell script. Is there any IDE for shell debug?
The following are my script:
================================================== ========
#! /bin/sh
x=`echo $0 | grep "^/"`
if test "${x}"; then
script_path=$(dirname "$0")
else
x=`echo $0 | sed -e 's/\.\///g'`
script_path=$(dirname `pwd`/${x})
fi
dir=/root/myproject/linux/shell/folder/
for file in `find ${dir} -type f`
do
new_folder=`sed -n 's,.*/\([a-z]*\).*\.jpg,\1,p' ${file}`
if [ ! -e ${new_folder} ]; then
#echo ${new_folder}
mkdir ${new_folder}
fi
done
================================================== ========
The above script return me "[: 18: feqefe: unexpected operator", what is the cause?
the contents of the "folder", actually, I want to ignore the .svn subfolder recursively. And I want to extract the "prefix" from file name, for example, extract dkefe from dkefe01dad.jpg, and created a subfolder named "dkefe",and move the dkefe01dad.jpg into that newly created subfolder.
================================================== ========
.svn dkefe01dad.jpg fdke01dad.jpg fefe01dad.jpg feqefe01dad.jpg
================================================== ========
I have difficultity at debuging the shell script. Is there any IDE for shell debug?
The following are my script:
================================================== ========
#! /bin/sh
x=`echo $0 | grep "^/"`
if test "${x}"; then
script_path=$(dirname "$0")
else
x=`echo $0 | sed -e 's/\.\///g'`
script_path=$(dirname `pwd`/${x})
fi
dir=/root/myproject/linux/shell/folder/
for file in `find ${dir} -type f`
do
new_folder=`sed -n 's,.*/\([a-z]*\).*\.jpg,\1,p' ${file}`
if [ ! -e ${new_folder} ]; then
#echo ${new_folder}
mkdir ${new_folder}
fi
done
================================================== ========
The above script return me "[: 18: feqefe: unexpected operator", what is the cause?
the contents of the "folder", actually, I want to ignore the .svn subfolder recursively. And I want to extract the "prefix" from file name, for example, extract dkefe from dkefe01dad.jpg, and created a subfolder named "dkefe",and move the dkefe01dad.jpg into that newly created subfolder.
================================================== ========
.svn dkefe01dad.jpg fdke01dad.jpg fefe01dad.jpg feqefe01dad.jpg
================================================== ========