Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
08-19-2010, 04:51 AM
|
#16
|
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,037
|
It's not something tricky like the file has been copied from a windows machine?
If you create a new file like:
Code:
jenhbvne
#kjeopb
rhiob
and then run the sed, does it leave only 2 lines?
|
|
|
08-19-2010, 04:59 AM
|
#17
|
Member
Registered: Jun 2007
Location: South Africa
Distribution: Linux Mint,Fedora, openSUSE, RHEL, SLES, Scientific Linux
Posts: 71
Original Poster
Rep:
|
It does indeed change it!
|
|
|
08-19-2010, 05:03 AM
|
#18
|
Senior Member
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
|
Perhaps with grep also:
Code:
grep -v '^[[:blank:]]*\(\#.*\)\?$' file
Edit: I'm not sure if # needs to be escaped.
Last edited by konsolebox; 08-19-2010 at 05:04 AM.
|
|
|
08-19-2010, 05:05 AM
|
#19
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
Hi,
Has to be something typical to your distro/sed version
Just tested it on Debian Squeeze, Lenny and RHEL5.3 and works as expected.
Code:
sed -i '/^$/d' testfile
only removes the blank lines and leaves comment lines alone.
Very strange indeed!
Kind regards,
Eric
|
|
|
08-19-2010, 06:31 AM
|
#20
|
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,037
|
I am with Eric, I tried it in Ubuntu, Sourcemage, Slackware (live cd) and my own source distro and all have behaved the same with only removing blank lines
and leaving comments (using ^$ as regex)
|
|
|
All times are GMT -5. The time now is 08:44 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|