【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 #

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22664653/viewspace-689620/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22664653/viewspace-689620/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值