我注意到我的目录中有很多文件,称为"sedAbCdEf"等.
/tmp/
吗?更新:
我检查了脚本,直到找到了制作文件的脚本.以下是一些示例代码:
#!/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
Run Code Online (Sandbox Code Playgroud)
如果您使用-i
选项(这意味着在场内进行更改)sed
写入临时文件,然后将其重命名为您的文件.因此,如果操作中止,则文件保持不变.
您可以看到哪些文件被打开,重命名为strace
:
$ strace -e open,rename sed -i 's/a/b/g' somefile
Run Code Online (Sandbox Code Playgroud)
注意:somefile
以只读方式打开.
似乎没有办法覆盖备份目录.GNU sed总是写在文件的目录(±symlinks)中.从sed/execute.c:
if (follow_symlinks)
input->in_file_name = follow_symlink (name);
else
input->in_file_name = name;
/* get the base name */
tmpdir = ck_strdup(input->in_file_name);
if ((p = strrchr(tmpdir, '/')))
*(p + 1) = 0;
else
strcpy(tmpdir, ".");
Run Code Online (Sandbox Code Playgroud)
前缀sed
是硬编码的:
output_file.fp = ck_mkstemp (&input->out_file_name, tmpdir, "sed");
Run Code Online (Sandbox Code Playgroud)