Question: I'd like to print next two line on "\*Apple" line.

```
$cat file.txt   
*Apple   
1234  
abcd  
*Apple  
4567  
dcba  
*Apple  
6789  
qwer  
*Apple  
6890  
rewq

```

Desired output: 

```
*Apple 1234 abcd   
*Apple 4567 dcba  
*Apple 6789 qwer   
*Apple 6890 rewq

```

I want solution using awk.

Answer: 
```
awk -vt=-1  '
/^\*Apple\s*$/ { if (t > -1) print ""; t = 2; printf("%s", $0); next }
t > 0          { t--; printf(" %s", $0) }
' file

```

*Input*

```
*Apple
111
222
aaa
*Apple
333
*Apple
*Apple
444

```

*Output*

```
*Apple 111 222
*Apple 333
*Apple
*Apple 444

```

Note, `\s` is [gawk-specific](https://www.gnu.org/software/gawk/manual/html_node/GNU-Regexp-Operators.html). For other AWK implementations use `[[:space:]]` instead.
The question is not well specified (do you only want two lines, or is it just that your particular example has exactly two lines after each occurrence of the target string?), but perhaps this gets you started:

```
awk '/^\*Apple$/{print "\n"}1; END{print "\n"}' ORS=' ' input

```

This one only prints 2 lines but will generate a spurious space at the start of most lines:

```
awk '/^\*Apple$/{c=3}c;  c--==1 {print "\n"}' ORS=' ' input

```

And you can lose the leading space with:

```
awk '/^\*Apple$/{c=3} c {printf "%s%c", $0, c--==1 ? "\n":" "}' input

```