D
D
DenZel2020-02-24 11:37:55
linux
DenZel, 2020-02-24 11:37:55

How to delete everything up to a certain word in a file?

Hello!
There is a file with content, for example:
For is me my dir ....
Test me file remove gants
How to remove everything in it, leaving only the word gants Of
course, I would like it to be idempotent,
Using or lineinfile, replace.
Can't find regex regex.
Tell me, thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Priluzkiy, 2020-02-24
@gen4_gdm

buff=$(grep -o "gants" filename)&&echo $buff > fulename

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question