结合两个sed命令 [英] combine two sed commands

查看:91
本文介绍了结合两个sed命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何组合以下两个sed命令。

How can I combine the following two sed commands.

一个循环目录中的所有文件,并从中删除第一行。
另一个从文件行的开头删除所有双引号。

One loops all files in a directory and removes the first line from them. The other removes any double quotes " from the start of file lines.

删除每个文件的第一行

for each in `/bin/ls -1`;do sed -i 1d $each;done

行的开头

for each in `/bin/ls -1`;do sed -i 's/^"//g' $each;done


推荐答案

您可以执行以下操作:

for each in *; do sed -i.bak 's/^"//g; 1d' "$each"; done

这篇关于结合两个sed命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆