sed为什么会留下很多文件? [英] Why does sed leave many files around?

查看:69
本文介绍了sed为什么会留下很多文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到目录中有很多文件,称为"sedAbCdEf"或此类文件.

I noticed many files in my directory, called "sedAbCdEf" or such.

  • 为什么创建这些文件?
  • 在脚本运行后,它们有什么价值吗?
  • 我可以将这些文件发送到其他位置吗?/tmp/?

更新:

我检查了脚本,直到找到制作文件的脚本.这是一些示例代码:

I checked the scripts until I found one which makes the files. Here is some sample code:

#!/bin/bash
a=1
b=`wc -l < ./file1.txt`
while [ $a -le $b ]; do
    for i in `sed -n "$a"p ./file1.txt`; do
        for j in `sed -n "$a"p ./file2.txt`; do
            sed -i "s/$i/\nZZ$jZZ\n/g" ./file3.txt
            c=`grep -c $j file3.txt`
            if [ "$c" -ge 1 ]
            then
                echo $j >> file4.txt
                echo "Replaced "$i" with "$j" "$c" times ("$a"/"$b")."
            fi
                echo $i" not found ("$a"/"$b")."
            a=`expr $a + 1`
        done
    done
done

推荐答案

  • 为什么创建这些文件?
  • sed -i"s/$ i/\ nZZ $ jZZ \ n/g" ./file3.txt

    -i 选项使 sed 将标准输出存储到临时文件中.
    完成 sed 后,它将重命名此临时文件以替换原始的 file3.txt .
    如果在运行 sed 时出现问题,则这些 sedAbCdE 临时文件将保留在此处.

    the -i option makes sed stores the stdout output into a temporary file.
    After sed is done, it will rename this temp file to replace your original file3.txt.
    If something is wrong when sed is running, these sedAbCdE temp files will be left there.

    • 在脚本运行后,它们有什么价值吗?

    您的旧文件未更改.通常不会.

    Your old file is untouched. Usually no.

    • 我可以将这些文件发送到其他位置吗,例如/tmp/?

    是的,请参见上文.

    请参见以供进一步阅读.

    see this for further reading.

    这篇关于sed为什么会留下很多文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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