The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-19-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,231
Quote:
Originally Posted by mskarica
I'm trying to use grep to get the line number only. This is the command I'm using:
grep -n "Content-Disposition: attachment" mbox

The output I get is:
45:Content-Disposition: attachment; filename="test.txt"

So now I just want to get the line number (45) from this output.

Can someone help me with this? Thanks
Code:

grep -n "Content-Disposition: attachment" mbox | sed -n 's/^\([0-9]*\)[:].*/\1/p'