1
我有一個腳本需要添加邏輯,如果有人從winscp添加文件並且不在轉換時轉換爲純文本。所以有些時候我們會得到一些特殊的字符(^ m),我想刪除它們 這是我的代碼。需要在Unix腳本中添加邏輯從Windows轉換爲Unix格式
cd $HOME_DIR
if [ $SHELL_STEP = 'step2' ]; then
if [ -s $DATA_DIR/$DATA_FILE.txt ]; then echo "The data file is present." cat -v new_reguest.txt $ awk '{ sub("\r$", ""); print }' new_request.txt > new_request.txt echo "Data file $DATA_FILE.txt found in $DATA_DIR directory." >> $LOG_FILE echo "" >> $LOG_FILE STATUS='good' else echo "The data file has not arrived yet." fi
if [ $STATUS = 'bad' ]; then
echo "The data file not found."
echo "The data file not found." >> $LOG_FILE
echo "" >> $LOG_FILE
SHELL_STEP='step5'
else
SHELL_STEP='step3'
fi
fi
我試圖用awk
命令,但它不是看起來很不錯。
請協助。
我認爲你正在尋找這個:http://stackoverflow.com/a/5446956/78845 – Johnsyweb 2012-02-27 08:58:50