/ html / resources / bash-tools / cleanup / cleanup.html
cleanup.html
  1  <!DOCTYPE html>
  2  <html lang="de">
  3     <head>
  4        <meta charset="UTF-8" />
  5        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6        <meta http-equiv="onion-location" content="http://bopbopl6lohkl2rts3ltesjnag4hzs4jrx2h6k6etgq5xasbpqekzlqd.onion" />
  7        <title>BOP Resources: cleanup.sh</title>
  8        <link rel="stylesheet" href="/assets/stylesheet.css" />
  9        <link rel="icon" type="image/x-icon" href="/assets/img/favicon.png">
 10     </head>
 11     <body>
 12         <header>
 13            <!-- --------------------------------------------------------------------------------------------------------------------------------- -->
 14            <script src="/assets/js/navbar-OpenClose.js"></script>
 15            <script src="/assets/js/lightbox.js"></script>
 16            <script src="/assets/js/copyCodeButton.js"></script>
 17            <link rel="stylesheet" href="/resources/js-libraries/highlightJS/atom-one-dark.min.css">
 18            <script src="/resources/js-libraries/highlightJS/highlight.min.js"></script>
 19            <script src="/resources/js-libraries/highlightJS/highlightjs-line-numbers.min.js"></script>
 20            <script>hljs.highlightAll();</script>
 21            <script>hljs.initLineNumbersOnLoad();</script>
 22            <!-- --------------------------------------------------------------------------------------------------------------------------------- -->
 23            <div class="branding">
 24               <button class="toggle-btn-navbar" id="navbarOpenButton">☰</button>
 25               <a href="/">
 26               <img class="logo" src="/assets/img/logo.png">
 27               </a>
 28               <div class="typing-animation">BytesOfProgress</div>
 29            </div>
 30         </header>
 31         <div id="navbarContainer" class="navbar-container">
 32            <iframe class="navbar-iframe" src="/assets/navbar/navbar.html" frameBorder= "0"></iframe>
 33         </div>
 34        <main>
 35  <!-- --------------------------------------------------------------------------------------------------------------------------------- -->
 36  
 37  <article class="site-post">
 38     <header class="post-header">
 39        <h1 class="post-title">cleanup.sh</h1>
 40        <div class="post-meta">
 41        </div>
 42     </header>
 43  </article>
 44  
 45  <nav class="breadcrumb">
 46    <a href="/">Home</a>
 47    <span class="divider">›</span>
 48    <a href="/resources/">Resources</a>
 49    <span class="divider">›</span>
 50    <a href="/resources/bash-tools/bash-tools.html">BASH-Tools</a>
 51    <span class="divider">›</span>
 52    <span class="current">cleanup.sh</span>
 53  </nav>
 54  
 55  <section class="post-content">
 56  
 57  <!-- --------------------------------------------------------------------------------------------------------------------------------- -->
 58  
 59  
 60  <p>
 61    This script removes lines with "0.0.0.0" or "127.0.0.1" at the beginning of the line.
 62    Useful for DNS-Blocklists.
 63  </p>
 64  
 65  <p>
 66    Get file:
 67  </p>
 68  
 69  <blockquote>
 70    $ wget https://bytesofprogress.net/resources/bash-tools/cleanup/cleanup.sh
 71  </blockquote>
 72  
 73  <p>
 74    Contents of file:
 75  </p>
 76  
 77  <div class="code-box">
 78    <pre><code>#!/bin/bash
 79  
 80  INPUTFILE="input.txt"
 81  OUTPUTFILE="output.txt"
 82  
 83  # Does file exist?
 84  if [ ! -f "$INPUTFILE" ]; then
 85      echo "ERROR: File $INPUTFILE does not exist!"
 86      exit 1
 87  fi
 88  
 89  # Removes lines with "0.0.0.0" or "127.0.0.1" at the beginning of the line.
 90  sed -E 's/^(0.0.0.0|127.0.0.1)[[:space:]]+//g' "$INPUTFILE" | sort -u > "$OUTPUTFILE"
 91  
 92  # Show line count before and after.
 93  echo "Output saved as: $OUTPUTFILE"
 94  echo "Original: $(wc -l < "$INPUTFILE") lines | Cleaned: $(wc -l < "$OUTPUTFILE") Lines."</code></pre>
 95  </div>
 96  
 97  <br />
 98  
 99  <!--------------------------------------------------------------------------------------------------------------------------------->
100  
101  <!-- --------------------------------------------------------------------------------------------------------------------------------- -->
102  
103     <hr>
104     </section>
105     <footer class="post-footer">
106     <a href="/resources/bash-tools/bash-tools.html" class="cta-button">← Back</a>
107     </footer>
108     </main>
109     </body>
110     </html>