remove '^M' in shell script
近期在windows上编辑一些shell脚本后上传到交换机框体上。
但这些shell脚本无法运行,每一行结尾都有'^M',同一时候框体上又没有dos2unix工具。
这么多脚本也不可能一行一行来改动。于是就自己写了一个脚本来把当前文件夹下全部文件里的'^M'去掉。
#!/bin/sh
filename='ls'
for f in ${filename};do
if [ -f ${f} ]; then
echo "delete '^M' and rename file to ${f}1"
tr -d "\015" <${f}> ${f}1
echo "Back to the original file name"
mv ${f}1 ${f}
fi
done
ll --color
remove '^M' in shell script的更多相关文章
- How to Create a First Shell Script
How to Create a First Shell Script Shell scripts are short programs that are written in a shell pr ...
- Shell Script Basics
https://developer.apple.com/library/mac/documentation/OpenSource/Conceptual/ShellScripting/shell_scr ...
- shell及脚本4——shell script
一.格式 1.1 开头 必须以 "# !/bin/bash" 开头,告诉系统这是一个bash shell脚本.注意#与!中间有空格. 二.语法 2.1 数值运算 可以用decla ...
- shell script
一.shell script的编写与执行 1.shell script 的编写中还需要用到下面的注意事项: a.命令的执行是从上到下,从左到右地分析与执行 b.命令.参数间的多个空白都会被忽略掉 c. ...
- (copy) Shell Script to Check Linux System Health
source: http://linoxide.com/linux-shell-script/shell-script-check-linux-system-health/ This article ...
- shell script练习
执行脚本的几种方式: 1. sh a.sh 或者 bash a.sh 调用的是 /bin/bash 进程执行的,所以脚本不需要执行权限. 2. 直接使用绝对路径执行, /home/script/a ...
- 这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script
这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script ##转载注明出处:http://www.cnblogs.com/wade-xu/p/4378224.html ...
- CentOS Linux下一个tomcat起停,查看日志的shell script
CentOS 的tomcat安装目录:/usr/local/tomcat vi MyTomcatUitl.sh 创建文件chmod u+x MyTomcatUtil.sh 赋执行 ...
- Shell script for logging cpu and memory usage of a Linux process
Shell script for logging cpu and memory usage of a Linux process http://www.unix.com/shell-programmi ...
- shell script入门
从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来看,Shell是用户与Linux操作系统沟通的桥梁.用户既可以输入命令执行,又可以利用 Shell脚本编程,完成更加复杂的操 ...
随机推荐
- [Codeforces 1053B] Vasya and Good Sequences
Link: Codeforces 1053B 传送门 Solution: 其实就是暴力 观察需要满足的条件: 1.个数和为偶数 2.最大个数不大于其它所有个数的和 如果只有第一个条件记录前缀和的奇偶性 ...
- 【期望DP+高斯消元】BZOJ3270-博物馆
[题目大意] 有m条走廊连接的n间房间,并且满足可以从任何一间房间到任何一间别的房间.两个男孩现在分别处在a,b两个房间,每一分钟有Pi 的概率在这分钟内不去其他地方(即呆在房间不动),有1-Pi 的 ...
- python安装BeautifulSoup
1.先下载pip https://pypi.python.org/pypi/pip 安装pip cd到路径 python setuo.py install 2.添加目录到环境变量中 xxx\Pytho ...
- Problem A: 自定义函数strcomp(),实现两个字符串的比较
#include<stdio.h> int strcmp(char *str1,char *str2) { if(str1!=NULL&&str2!=NULL) { whi ...
- python使用sqlite示例
SQLite是一种嵌入式数据库,它的数据库就是一个文件.Python就内置了SQLite3,所以,在Python中使用SQLite,不需要安装任何东西,直接使用. 操作关系数据库,首先需要连接到数据库 ...
- sqlserver 计算数据库时间差
介绍:datediff(datepart,startdate,enddate) 返回间隔datepart 的数 SELECT datediff(yy,'2010-06-1 10:10',GETDATE ...
- Weui 文件上传完整版示例
部分思路借用网友,部分是自己细化的. 先声明. 不多说,参考代码 @{ ViewBag.Title = "费用填报"; Layout = "~/Views/Shared/ ...
- 基于 Dapper 的一个 DbUtils
/// <summary> /// v1.0 /// </summary> public partial class DbUtils { string ConnectionSt ...
- Google Breakpad 完全解析(二) —— Windows前台实现篇
原创文章,转载请标明出处:Soul Apogee (http://bigasp.com),谢谢. 好,看完了如何使用breakpad,我们现在看看breakpad在Windows下到底是如何实现的呢? ...
- golang错误处理机制:panic与recover
原文地址:http://www.niu12.com/article/14 panic知识点 package main import ( "fmt" "github.com ...