I am working on a latex file from which I need to pick out the references marked by \citep{}. This is what I am doing using sed. 

```
    cat file.tex | grep citep | sed 's/.*citep{\(.*\)}.*/\1/g'

```

Now this one works if there is only one pattern in a line. If there are more than one patterns i.e. \citep in a line, it fails. It fails even when there is only one pattern but more than one closing bracket }. What should I do, so that it works for all the patterns in a line and also for the exclusive bracket I am looking for?

I am working on bash. And a part of the file looks like this:

```
of the Asian crust further north \citep{TapponnierM76, WangLiu2009}. This has led to widespread deformation both within and 
\citep{BilhamE01, Mitraetal2005} and by distributed seismicity across the region (Fig. \ref{fig1_2}). Recent GPS Geodetic 
across the Dawki fault and Naga Hills, increasing eastwards from $\sim$3~mm/yr to $\sim$13~mm/yr \citep{Vernantetal2014}. 
GPS velocity vectors \citep{TapponnierM76, WangLiu2009}. Sikkim Himalaya lies at the transition between this relatively simple 
this transition includes deviation of the Himalaya from a perfect arc beyond 89\deg\ longitude \citep{BendickB2001}, reduction 
\citep{BhattacharyaM2009, Mitraetal2010}. Rivers Tista, Rangit and Rangli run through Sikkim eroding the MCT and Ramgarh 
thrust to form a mushroom-shaped physiography \citep{Mukuletal2009,Mitraetal2010}. Within this sinuous physiography, 
\citep{Pauletal2015} and also in accordance with the findings of \citet{Mitraetal2005} for northeast India. In another study 
field results corroborate well with seismic studies in this region \citep{Actonetal2011, Arunetal2010}. From studies of 

```

On one line, I get answer like this 

```
    BilhamE01, TapponnierM76} and by distributed seismicity across the region (Fig. \ref{fig1_2

```

whereas I am looking for 

```
    BilhamE01, TapponnierM76

```

Another example with more than one /citep patterns gives output like this

```
    Pauletal2015} and also in accordance with the findings of \citet{Mitraetal2005} for northeast India. In another study

```

whereas I am looking for

```
    Pauletal2015 Mitraetal2005

```

Can anyone please help?