巴什sed的环路 [英] Bash sed in loop

查看:146
本文介绍了巴什sed的环路的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用后续替代几个文件,逗号标签:

I'm trying to use the follow to substitute the tab with comma in several file:

#!/bin/sh 
for i in *output_*.txt  
do   
sed 's/ /;/g' $i > $i 
done

但它不工作,因为在输出文件中我仍然有标签分隔符。它,当我使用它在一个单一的文件,而无需在for循环只是工作。

But it is not working because in the output file I still have the tab delimiter. It just work when I'm using it on a single file without the for loop.

任何帮助吗?

感谢。

推荐答案

有几件事情是错误的。 Unqouted变量输出重定向到同一个文件。也没有必要循环。

Several things are wrong. Unqouted variables and output redirection into same file. Loop is also not needed.

尝试:
     SED -i'S / / /克'。*输出_ * TXT

这篇关于巴什sed的环路的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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