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 है.























{ 1 trackback } (1) Trackback
{ 4 comments… read them below or (4 टिप्पणियाँ ... उन्हें या नीचे पढ़ें add one एक जोड़ } )
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.lstI get this error मैं इस त्रुटि मिलती है
sed: -e expression #1, char 1: unknown command: ` 'bash: /^: No such file or directoryNote 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 पॉल
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.newStill 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 अब भी नहीं यकीन है कि लेख में दिए गए आदेश के साथ बिल्कुल गलत क्या है, लेकिन यह हो सकता है कि एचटीएमएल 'किसी भी तरह' विकृत पहली एकल उद्धरण चिह्न है
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/hi, is this the same as: नमस्ते है, यह के रूप में ही:
grep -v '#' file grep 'वी' # संचिका
Leave a Comment एक टिप्पणी छोड़ दो