There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus batch bios bsod computer crash driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop lcd malware memory monitor motherboard mouse network printer problem ram registry router security server slow software sound svchost.exe trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
SED Help

Reply  
Thread Tools
surfnschultz's Avatar
Member with 191 posts.
 
Join Date: Nov 2003
03-Apr-2006, 03:22 PM #1
SED Help
I have a file with blank lines I want to remove.

I tried s/^$/d but it failed

I also want to take 2 lines and concat them.

123456
123456 this is the title

I want the output to be 123456 123456 this is the title

Any clues?
tsunam's Avatar
Senior Member with 1,246 posts.
 
Join Date: Sep 2003
Experience: Linux~su
03-Apr-2006, 04:36 PM #2
:g/^$/d should hopefully work for removing blank lines might be ^*$

I know that ^[ t]*$ does for blanks spaces and tabs if I recall. I'll poke back later with the concat. for that you might look at awk's print though.
surfnschultz's Avatar
Member with 191 posts.
 
Join Date: Nov 2003
03-Apr-2006, 04:48 PM #3
Thanks tsuman BUT
I found out hte lines are blank space padding NOT blank new lines.

I tried a few things and mostly messed the file up.

I will try soem rmoe, got any good ideas on how to remove spaces with messing up the other single space between words on the lines I want to preserve?
Squashman's Avatar
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
06-Apr-2006, 12:15 AM #4
Sed One Liners is great web page.

# delete BOTH leading and trailing whitespace from each line
sed 's/^[ \t]*//;s/[ \t]*$//'

# delete ALL blank lines from a file (same as "grep '.' ")
sed '/^$/d' # method 1
sed '/./!d' # method 2


http://sed.sourceforge.net/sed1line.txt

I would think that combination should work.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 10:30 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.