ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【shell 脚本】删除 由windows传入linux含有的 ^M

【shell 脚本】删除 由windows传入linux含有的 ^M

原创 Linux操作系统 作者:杨奇龙 时间:2011-03-16 14:55:06 0 删除 编辑
#!/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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
MySQL DBA NoSQL DEVOPS

注册时间:2009-10-07

  • 博文量
    1026
  • 访问量
    7698763