I have a process which outputs too many status-lines with carriage return (\r). I can filter all those status lines by piping them through
sed '/\r/d'
I would instead like to filter all of these lines except, e.g. every 3. Is this possible with standard Unix-Tools (awk?) or do I need a script for that? Lines without CR should be left untouched.
Given Output:
$ (printf '%s\n' {1..10}; printf '%s\r\n' {1..10}; printf '%s\n' {1..10};) | cat -v
1
2
3
4
5
6
7
8
9
10
1^M
2^M
3^M
4^M
5^M
6^M
7^M
8^M
9^M
10^M
1
2
3
4
5
6
7
8
9
10
Wanted output (or any other pattern):
1
2
3
4
5
6
7
8
9
10
1^M
4^M
7^M
10^M
1
2
3
4
5
6
7
8
9
10