您的位置:首页 > 其它

How to handle the space in column with awk?

2013-10-15 15:20 525 查看
It happens when check non version controlled files in SVN folder and some file names are with space like:

?      ABC DEF

?      HIUHOJ

?      NDJIH JI

The main point is to get the file name like:

ABC DEF

HIUHOJ

NDJIH JI

-----------code---------------------------

${SVN} status |grep "?" > "${LOG_FOLDER}/${BUS_NAME}/new_add_file.txt"

cat "${LOG_FOLDER}/${BUS_NAME}/new_add_file.txt"|while read line

do

fn=`echo $line|awk '{print NF}'`

if [ "$fn" = "0" ]; then

  break

fi

i=0;

f1=""

f2=""

for fd in $line

do

i=`expr $i + 1 `

if [ "$i" = "1" ]; then

f1=$fd

fi

fsec=`expr $fn - 1`

if [ "$i" = 2 ]; then

f2=$fd

fi

  if [ "$i" = 3 ];then

    f2=$f2" "$fd

  fi

done

${SVN} add "${f2}"

done

-------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐