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 -->
  #6 (permalink)  
Old 03-19-2009
rikxik's Avatar
rikxik rikxik is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 250
Code:
$ cat sd
sed -n '/^$/!{
h
}
/^$/{
N
/^\n$/ {
x
p
q
}
}' fl
$
$ cat fl
someword someword:1
new-word new-word abcd
someword someword:10
new-word new-word abcd
thisis whatIneed:3


someword someword:5
new-word new-word abcd
$
$ sd
thisis whatIneed:3
Be careful when you cut paste this - there MUST NOT be any trailing spaces.

Last edited by rikxik; 03-19-2009 at 10:49 PM..