Unix: Grep Commands

Simple grep command to find a file content

by Joey Albert Abano

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.2.1/cerulean/bootstrap.min.css">
<div class="container">
<br>
<form>
  <div class="form-group">
    <label for="p">File path</label>
    <input type="text" id="p" class="form-control" placeholder="">
  </div>
 <div class="form-group">
    <label for="s">Search text</label>
    <input type="text" id="s" class="form-control" placeholder="">    
  </div>  
</form>
</div>
<div id="c" class="container">
<br>
The du -sh checks the directory size. <br>
Find a file in a directory by text content <br/>
grep -rnws '{path}' -e '{needle}' <br/>
grep -E '{needle}' *.* <br/>
du -sh {path} <br/>
grep -o '{needle}' {path} | wc -l <br/>

</div>

CSS

body {
  background:#222;
  color:#fff;
  
}

body, input {
  font-size:14px;
}

input { 
  width:100px; 
}

h1 {
  font-size:18px;
}

h2 {
  font-size:16px;
}

JavaScript

var p = document.getElementById('p');
var s = document.getElementById('s');
var r = document.getElementById('c');
var f = r.innerHTML;

p.addEventListener('keyup', update);
s.addEventListener('keyup', update);

function update() {
  r.innerHTML = f.replaceAll('{path}',p.value).replaceAll('{needle}',s.value);
}