M
M
mts20502020-02-05 10:47:53
linux
mts2050, 2020-02-05 10:47:53

How to delete lines with certain word and character combination in linux?

Tell me how to delete lines in linux containing a certain word and a combination of characters.
Such command deletes normally.
sed -i '/\"track":"3.00"/d' 1.txt
But I need to delete the same lines from 3 to 100.
I tried this. Does not work.
sed -i '/\"track":"/[3-100]/.00"/d' 1.txt
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
X
xotkot, 2020-02-05
@mts2050

something like this

awk '!/"track":"([3-9]|([1-9][0-9])|100).00"/' 1.txt

with writing to source file
awk -i inplace '!/"track":"([3-9]|([1-9][0-9])|100).00"/' 1.txt

C
CityCat4, 2020-02-05
@CityCat4

You can stupidly write a loop on the bash with iteration from 3 to 100 and issuing the appropriate command.

K
ky0, 2020-02-05
@ky0

https://regex101.com/
Compose a regexp, check for a match below.
Obviously, you need to add one to three digits to the capture group.

R
Radjah, 2020-02-05
@Radjah

If the entire lines are straight, thencat file | grep -v выражение > file2

S
SOTVM, 2020-02-05
@sotvm

smoke parameters -n and global g
I will not give an example = bookoy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question