R
R
rkey_rs2022-03-04 16:13:16
bash
rkey_rs, 2022-03-04 16:13:16

How to find a specific character in a line of a file and perform an action (sh) on that line?

I welcome everyone. Given is a file that contains lines like:

Mik_01-01-1990.rvk:0
Mik_02-01-1990.rvk:1
Mik_03-01-1990.rvk:1
Mik_04-01-1990.rvk:2


It is necessary to determine the lines ending with ":0" by enumeration, collect them into one list and write them to a file.

I tried but did not understand how to implement it correctly. Maybe there are other options?
while IFS= read -r line

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2022-03-04
@rkey_rs

cat yourfile.txt | grep -E ':0$' > otherfile.txt

K
ky0, 2022-03-04
@ky0

You can bury zero with the end-of-line character.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question