as tittle, how sed perform "greater than" to delete specific line?
I got a file like this:
bash-4.2$ cat testfile.txt
string1 1 1
AAA 2 2
string2 2 2
BBB 3 3
string3 3 3
string4 4 4
string5 5 5
string6 6 6
CCC 6 6
string7 7 7
string8 8 8
string9 9 9
string10 10 10
DDD 11 11
string11 11 11
string12 12 12
string13 13 13
I wanna delete some lines which contains "string[[:digit:]]" but string1 to string"$num" is needed, num is defined by a variable. For example, I wanna keep those lines which contains string1-5 and delete string6-string99, I'd tried:
#!/bin/bash
read -p "Please Assign the Number of String Line that You Wanna Keep: " num
cat testfile.txt | sed -e "/string[`expr $num + 1`-9]/d" > new_testfile.txt
but it's only working in range 0-8, is there any way to perform it with sed or awk?