【shell 指令碼】刪除 由windows傳入linux含有的 ^M
#!/bin/bash
function usage(){
echo "Usage: `basename $0 ` source_file new_file "
exit 0
}
[ $# != 2 ] && usage
cat $1 | tr -d "\r" > $2
chmod 755 $2
exit 0
=========測試==========
"varify_ture.sh" [converted][dos] 119L, 2611C written
root@client.example.com ~/yang # ./varify_ture.sh
: command not foundine 2:
: command not foundine 6:
: command not foundine 7: echo
: command not foundine 8:
Testing "0"
./varify_ture.sh: line 15: syntax error near unexpected token `fi'
./varify_ture.sh: line 15: `fi # 0 Ϊ'
===================================
root@client.example.com ~/yang # ./dropblank.sh varify_ture1.sh varif_2.sh
root@client.example.com ~/yang # ./varif_2.sh
Testing "0"
0 is true.
Testing "1"
1 is true.
Testing "-1"
-1 is true.
Testing "NULL"
NULL is false.
Testing "xyz"
Random string is true.
Testing "$xyz"
Uninitialized variable is false.
Testing "-n $xyz"
Uninitialized variable is false.
Testing "-n $xyz"
Null variable is false.
Testing "false"
"false" is true.
Testing "$false"
"$false" is false.
root@client.example.com ~/yang #
function usage(){
echo "Usage: `basename $0 ` source_file new_file "
exit 0
}
[ $# != 2 ] && usage
cat $1 | tr -d "\r" > $2
chmod 755 $2
exit 0
=========測試==========
"varify_ture.sh" [converted][dos] 119L, 2611C written
root@client.example.com ~/yang # ./varify_ture.sh
: command not foundine 2:
: command not foundine 6:
: command not foundine 7: echo
: command not foundine 8:
Testing "0"
./varify_ture.sh: line 15: syntax error near unexpected token `fi'
./varify_ture.sh: line 15: `fi # 0 Ϊ'
===================================
root@client.example.com ~/yang # ./dropblank.sh varify_ture1.sh varif_2.sh
root@client.example.com ~/yang # ./varif_2.sh
Testing "0"
0 is true.
Testing "1"
1 is true.
Testing "-1"
-1 is true.
Testing "NULL"
NULL is false.
Testing "xyz"
Random string is true.
Testing "$xyz"
Uninitialized variable is false.
Testing "-n $xyz"
Uninitialized variable is false.
Testing "-n $xyz"
Null variable is false.
Testing "false"
"false" is true.
Testing "$false"
"$false" is false.
root@client.example.com ~/yang #
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-689620/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 利用PHP指令碼刪除MySQL上所有的表PHP指令碼MySql
- MySQL 批量更新、刪除資料shell指令碼MySql指令碼
- Windows Linux 刪除N天之前的檔案指令碼WindowsLinux指令碼
- 【shell 指令碼】刪除/var/log 下的日誌指令碼
- shell指令碼之刪除固定天數之前的檔案指令碼
- rhel5_shell_刪除重建使用者user_匯入dmp_指令碼指令碼
- Linux Shell指令碼Linux指令碼
- Linux shell 指令碼Linux指令碼
- windows下自動刪除過期檔案的指令碼Windows指令碼
- 日誌刪除指令碼指令碼
- Linux/Unix shell 引數傳遞到SQL指令碼LinuxSQL指令碼
- Linux shell 指令碼分享Linux指令碼
- shell 指令碼的除錯問題指令碼除錯
- Shell指令碼匯入外部指令碼內容指令碼
- 刪除資料庫指令碼資料庫指令碼
- shell入門--第一個shell指令碼指令碼
- mysqldump壓縮備份匯出匯入(含定期備份shell指令碼)MySql指令碼
- linux shell小指令碼分享Linux指令碼
- linux常用的shell指令碼Linux指令碼
- 定時刪除檔案指令碼指令碼
- shell指令碼案例分享 - 業務系統日誌自定義保留或刪除需求指令碼
- Linux/Unix shell 指令碼中呼叫SQL,RMAN指令碼Linux指令碼SQL
- 傳送kafka訊息的shell指令碼Kafka指令碼
- shell指令碼:批次傳送curl請求指令碼
- shell 指令碼報錯^M: syntax error near unexpected token指令碼Error
- Linux基礎五(shell指令碼)Linux指令碼
- Linux 【Shell指令碼經典案例】Linux指令碼
- 【Linux】【Shell】主控指令碼實現Linux指令碼
- linux shell 指令碼攻略筆記Linux指令碼筆記
- Linux Shell指令碼系列之二Linux指令碼
- Linux Shell指令碼系列之一Linux指令碼
- Linux Shell 指令碼面試 25 問Linux指令碼面試
- Linux Shell指令碼面試25問Linux指令碼面試
- linux shell指令碼中 =~ 的作用Linux指令碼
- 資料匯入shell指令碼(下)指令碼
- 【shell 指令碼】兩種登入方式指令碼
- linux 刪除含斜槓的檔案的方法Linux
- shell指令碼中main函式中$#獲取不到指令碼傳入引數個數淺析指令碼AI函式