A
A
Antony2020-08-02 19:06:24
bash
Antony, 2020-08-02 19:06:24

How to cut lines in a file by criteria?

Hello colleagues. The task is this. I have an input - a .txt file that has lines, each containing entries like 55555,dif and 55555,bat. How do I cut only those lines that contain a dif in the string? Perhaps with cut or something else?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
vaut, 2020-08-02
@anton-gm

grep -v dif file.txt > out.txt

D
Dmitry, 2020-08-02
@gebrak

sed -i.bak '/dif/d' filename.txt
filename.txtLines that contain text will be removed from the file dif. The file will be backed up before changes.

X
xotkot, 2020-08-02
@xotkot

for kit, on awk:
awk '!/dif/' file.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question