How to view a configuration file without the comments कैसे टिप्पणी के बिना एक विन्यास फाइल देखने के लिए

by Sukrit Dhandhania on May 22, 2009 Sukrit Dhandhania द्वारा 22 मई 2009 पर

लिनक्स

I have to often make changes to configuration files such as httpd.conf and squid.conf . मैं अक्सर ऐसे httpd.conf और squid.conf के रूप में विन्यास फाइल में परिवर्तन कर दिया है. These files have a large number of lines that are commented out, mostly comments and some possible configuration directives that have been commented out as they are not required by default. इन फ़ाइलों लाइनों की एक बड़ी संख्या है कि बाहर टिप्पणी की, ज्यादातर टिप्पणी और कुछ संभव विन्यास निर्देशों गया है कि बाहर टिप्पणी के रूप में डिफ़ॉल्ट रूप से वे आवश्यक नहीं हैं है. A problem I face while editing such files is that there are so many lines commented out that I need to scroll down many lines before I can find the next active configuration directive. मैं एक समस्या का सामना करते समय संपादन ऐसी फ़ाइलें यह है कि इतने सारे लाइनों रहे हैं टिप्पणी की है कि मैं नीचे कई लाइनों पुस्तक की जरूरत है इससे पहले कि मैं अगले सक्रिय विन्यास निर्देश पा सकते हैं. I found a fine solution to help me out with this. मैं एक अच्छा समाधान के लिए मुझे इस के साथ बाहर की मदद मिली.

I now use the following command when I want to just look at the active directives in the Apache configuration file: मैं अब निम्न कमांड का प्रयोग जब मैं बस एपाचे विन्यास में सक्रिय निर्देशों पर फ़ाइल देखना चाहता हूँ:

# sed '/ *#/d; /^ *$/d' /etc/httpd/conf/httpd.conf Sed # '/ * # /; ^ * $ / घ' / etc / / / httpd.conf conf / httpd घ

This command reads the file /etc/httpd/conf/httpd.conf and filters out all the comments and extra white spaces, leaving just the active configuration settings. यह कमांड फाइल / etc पुस्तकें / httpd / conf / httpd.conf और बाहर फ़िल्टर सभी टिप्पणियाँ और अतिरिक्त सफेद रिक्त स्थान, जा रही बस सक्रिय विन्यास सेटिंग्स. This makes it very easy for me to look at the configuration file. यह बहुत आसान मेरे लिए विन्यास फाइल को देखने के लिए करता है.

If you want to just filter out the lines that begin with comments run the following command: यदि आप लाइनों है कि टिप्पणी के साथ शुरू से ही फिल्टर करना चाहते निम्न कमांड चलायें:

# sed '/ ^#/d; /^ *$/d' /etc/httpd/conf/httpd.conf 'Sed / ^ # / d; ^ * $ / घ' / etc / / / httpd.conf conf / httpd #

It's pretty much the same command as earlier with a small change. यह बहुत सुंदर है के रूप में एक ही पहले कमान एक छोटे से बदलाव के साथ. The first * is replaced by ^ , which is regex for beginning of line. * पहले की जगह ^ है, जो लाइन की शुरुआत के लिए regex है.

Related Posts: संबंधित पोस्ट:
  • How to open and view .cbr and .cbz files कैसे और खोलने के लिए देखें. सीबीआर और. Cbz फ़ाइलें
  • How to view the page source in a new tab using Firefox कैसे एक नए टैब में पृष्ठ के स्रोत को देखने के लिए Firefox का उपयोग
  • Contact संपर्क
  • How to create a symlink (shortcut) in Linux कैसे बनाने के एक लिनक्स में (शॉर्टकट) symlink को
  • 10 more brightkite invites for Simple Help readers 10 अधिक brightkite सरल सहायता पाठकों के लिए आमंत्रित
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! बस अपने ईमेल इनबॉक्स के लिए मुफ्त हर दिन - में यह एक तरह सरल सहायता ट्यूटोरियल जाओ! Just enter your email address below: बस नीचे अपना ईमेल पता दर्ज करें:

    You can always opt out of this email subscription at any time. तुम हमेशा इस ईमेल सदस्यता से बाहर किसी भी समय विकल्प चुन सकते हैं.

    { 1 trackback } (1) Trackback

    Display files without commented-out lines « Linux & Stuff प्रदर्शन के बिना फ़ाइलों टिप्पणी की आउट लाइन «लिनक्स और सामग्री
    05.31.09 at 3:51 am 3:51 पर 05.31.09 हूँ

    { 4 comments… read them below or (4 टिप्पणियाँ ... उन्हें या नीचे पढ़ें add one एक जोड़ } )

    1 1 paulfxh 05.30.09 at 3:20 pm 3:20 पर 05.30.09 paulfxh बजे

    Your command to show a file without comments could be very useful for me. अपने आदेश टिप्पणियाँ बिना किसी फाईल को दिखाने के लिए हो सकता है मेरे लिए बहुत उपयोगी है.
    However, when I tried to run लेकिन, मैं भागने की कोशिश की थी जब
    # sed '/ ^#/d; /^ *$/d' /boot/grub/menu.lst
    I get this error मैं इस त्रुटि मिलती है
    sed: -e expression #1, char 1: unknown command: ` '
    bash: /^: No such file or directory
    Note that I copied/pasted the command directly from your post. ध्यान दें कि मैं नकल / कमान सीधे अपने पद से चिपकाया.
    I have a feeling this may be a HTML-related problem. मुझे लगता है कि यह एक HTML संबंधी समस्या हो सकती है.
    Any clues? कोई सुराग?
    Thanks धन्यवाद
    Paul पॉल

    2 2 paulfxh 05.31.09 at 3:16 am 3:16 पर 05.31.09 paulfxh हूँ

    Well, after a bit of searching around, I found that this command does what I want ठीक है, के बाद आसपास की तलाश के एक बिट, मैंने पाया है कि यह आदेश है जो मैं चाहता हूँ
    sed '/^#/ d' /boot/grub/menu.lst>/boot/grub/menu.new
    Still not sure exactly what's wrong with the command given in the article, but it might be that the HTML has somehow 'distorted' the first single quote mark अब भी नहीं यकीन है कि लेख में दिए गए आदेश के साथ बिल्कुल गलत क्या है, लेकिन यह हो सकता है कि एचटीएमएल 'किसी भी तरह' विकृत पहली एकल उद्धरण चिह्न है

    3 3 paulfxh 05.31.09 at 3:33 am 3:33 पर 05.31.09 paulfxh हूँ

    After a little more experimentation, I find that the command below does what the command in the article was intended to do थोड़ा और प्रयोगों के बाद, मैं यह पाते हैं कि कमान नीचे है क्या अनुच्छेद की कमान करने का इरादा था
    sed '/^#/d; /^*$/d' /path/to/file/

    4 4 lxtips lxtips 06.29.09 at 10:03 pm 10:03 पर 06.29.09

    hi, is this the same as: नमस्ते है, यह के रूप में ही:

    grep -v '#' file grep 'वी' # संचिका

    Leave a Comment एक टिप्पणी छोड़ दो

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> आप ये HTML टैग और विशेषताएँ: <a href="" उपयोग title=""> <abbr title=""> <acronym कर सकते हैं <blockquote title=""> <b> cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>