R
R
rutaka nashimo2015-11-12 13:41:52
linux
rutaka nashimo, 2015-11-12 13:41:52

Why does awk erase part of a file?

I want to change the text according to the regular expression in the files
I write the following:

ag -rl regexp | xargs awk "{gsub(/regexp/, \"string\"); print > FILENAME}"

usually works fine, but on large files it cuts off the end of the file.
Why can this happen and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rutaka nashimo, 2015-11-13
@rutaka_n

Alas, I could not figure out how to fix it, but I found an alternative (sed came to the rescue)
the -i switch indicates in-place replacement and overwrites the file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question