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
-------------------------
? 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
-------------------------
相关文章推荐
- how to handle the c string and comments in flex
- how to get the space size of some tables in one database?
- How to identify all the Corrupted Objects in the Database reported with RMAN
- how to use the mathmatical constant "e" in conjunction with a vector
- How to change the name in open with list / File association.
- How To Manipulate Icons in the System Tray with Visual Basic
- How to fill the background with image in landscape in IOS? 如何使image水平铺满屏幕
- The transaction log for database 'wcadmin' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.datab
- How to deal with the "ErrorWebPart" error displayed in the web part maintenance page
- How to view the free space of your partitions in Ubuntu
- how to use a SQLite database in a standalone program with an HTML interface and VBScript as the programming language
- How to use isInEditMode() to see layout with custom View in the editor
- How to install Android SDK and play with Android 2.0 in the emulator
- how to handle with single quote in ms sql server
- How to implement the similar mechanism with Java final in c++?
- [Python]How to handle the exception in Python?
- How to execute the command with root jurisdiction in pyCharm
- How to Resolve the 'Error MSB6006 tsc.exe exited with code 2' build error in Visual Studio 2015
- What 's CATT(Computer Aided Test Tool)?How to deal with the CATT in the SAP System?什么是CATT(计算机附加测试工具)
- How to handle the session in HttpClient 4.1