LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-30-2005, 02:31 AM   #1
dhammika
Member
 
Registered: Dec 2003
Location: Colombo. (Sri Lanka)
Distribution: RH 9, RH AS 3, Fedora Core
Posts: 65

Rep: Reputation: 15
Vi view uncomment lines only


Hi all

how to view conf files like squid.cong to
view only uncomment lines ( lines with # should ignore)

thanks
 
Old 09-30-2005, 06:19 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
If you only need to view the file, I would use cat and grep....
Code:
cat file.txt | grep -v '#'
 
Old 09-30-2005, 08:41 PM   #3
dhammika
Member
 
Registered: Dec 2003
Location: Colombo. (Sri Lanka)
Distribution: RH 9, RH AS 3, Fedora Core
Posts: 65

Original Poster
Rep: Reputation: 15
thanks Ok 'la

If i need to edit the file how can i do it.....
 
Old 09-30-2005, 09:25 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Do you want to remove all of the comment lines?
 
Old 09-30-2005, 09:34 PM   #5
dhammika
Member
 
Registered: Dec 2003
Location: Colombo. (Sri Lanka)
Distribution: RH 9, RH AS 3, Fedora Core
Posts: 65

Original Poster
Rep: Reputation: 15
no ... just display the uncomments ..and edit them etc...



if not possible how can cat grep removing the bank line ( Referring to you previous solution)
 
Old 09-30-2005, 09:56 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
if not possible how can cat grep removing the bank line ( Referring to you previous solution)
I'm not sure why you would want to remove all comments and / or blank lines. If that is what you want to do, it may be easiest to put it into another file.
For example:
To get rid of all lines which start with # ( comments ) might look like this...
cat file.txt |grep -v "^#" > file1.txt

and to get rid of all blank lines might look like this...
cat file.txt |grep -v "^$" > file1.txt
 
Old 09-30-2005, 10:04 PM   #7
dhammika
Member
 
Registered: Dec 2003
Location: Colombo. (Sri Lanka)
Distribution: RH 9, RH AS 3, Fedora Core
Posts: 65

Original Poster
Rep: Reputation: 15
Quote:
I'm not sure why you would want to remove all comments and / or blank lines
problem is squid.conf is little large only few lines actually need to config.

any other trick to jump to uncomments line when navigating the vi

thanks
 
Old 10-01-2005, 12:10 AM   #8
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
no ... just display the uncomments ..and edit them etc...
Ok, I got it now.
Unfortunately, I didn't find any way to view lines that don't start with # .

The best hope I saw was to jump to end of paragraphs with the } .
 
Old 10-01-2005, 02:05 AM   #9
dhammika
Member
 
Registered: Dec 2003
Location: Colombo. (Sri Lanka)
Distribution: RH 9, RH AS 3, Fedora Core
Posts: 65

Original Poster
Rep: Reputation: 15
thanks for your help ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
printer printing vertical lines at beginning and end of lines makhand Linux - Hardware 0 09-02-2005 02:03 PM
vsftpd - comment/uncomment question. zaoka Linux - General 1 07-31-2005 01:09 AM
W2K cannot view samba share but can view NT FiveFlat Linux - Software 3 06-10-2005 02:54 PM
uncomment salviadud Linux - Newbie 1 02-08-2005 09:04 AM
uncomment? *huh?* teona Linux - Newbie 9 12-25-2003 10:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration