Answer
See the detailed answer below.
Work Step by Step
We know that the electric field exerted by an infinite line of charge at a distance $r$ is given by
$$E_{\rm line}=\dfrac{1}{4\pi \epsilon_0}\dfrac{2\lambda }{r}\hat r$$
Assuming that the direction of $\hat r$ is in the $x$-direction, so
$$E_{\rm line}=\dfrac{1}{4\pi \epsilon_0}\dfrac{2\lambda }{r}\hat i\tag 1$$
This electric field exerts an attractive electric force on the negative charge of the dipole which lies at a distance of $r_-=r-\frac{s}{2}$, and at the same time it exerts a repulsive force on the positive charge of the dipole which lies at $r_+=r+\frac{s}{2}$, as we see in the figure below.
The repulsive force is toward the right while the attraction force is toward the left.
Thus, the net electric force exerted on the dipole by the infinite line of charge is given by
$$F=F_+-F_-$$
$$F=qE_{\rm on +}-qE_{\rm on -}=q(E_{\rm on +}- E_{\rm on -})$$
Plug from (1),
$$F= q\left[ \dfrac{1}{4\pi \epsilon_0}\dfrac{2\lambda }{r_+}\hat i-\dfrac{1}{4\pi \epsilon_0}\dfrac{2\lambda }{r_-}\hat i \right]$$
$$F= \dfrac{2\lambda q}{4\pi \epsilon_0}\left[ \dfrac{1 }{r+(s/2)} - \dfrac{1}{r-(s/2)} \right]\hat i$$
$$F= \dfrac{2\lambda q}{4\pi \epsilon_0}\left[ \dfrac{r-(s/2)-[r+(s/2)]}{r^2-s^2/4} \right]\hat i$$
$$F= \dfrac{2\lambda q}{4\pi \epsilon_0}\left[ \dfrac{-s }{r^2-s^2/4} \right]\hat i$$
$$F= \dfrac{2\lambda q}{4\pi \epsilon_0}\left[ \dfrac{-s }{r^2\left(1-\dfrac{s^2}{4r^2}\right)} \right]\hat i$$
And since $r\gt \gt s$, so $\dfrac{s^2}{4r^2}\approx 0$
$$F= \dfrac{- 2\lambda s q}{4\pi \epsilon_0 r^2} \hat i$$
where $qs=p$, so
$$\boxed{F= \dfrac{- 2\lambda p}{4\pi \epsilon_0 r^2} \hat i}$$
The negative sign indicates that the net force is toward the left which is toward the line itself. Thus, it is an attractive force whose magnitude is given by
$$\boxed{F= \dfrac{ 2\lambda p}{4\pi \epsilon_0 r^2} }$$