Skip to content

Instantly share code, notes, and snippets.

@duyet
Last active August 29, 2015 14:17
Show Gist options
  • Save duyet/16df26b3d487411429aa to your computer and use it in GitHub Desktop.
Save duyet/16df26b3d487411429aa to your computer and use it in GitHub Desktop.
#!/bin/bash
# Find all string from input, and search all file (*.txt) contains this strings.
# Van-Duyet Le <[email protected]>
# Homepage: http://lvduit.com
ext="./*.txt"
read -p "Your input string: " input
echo 'List file containt "' $input '"'
# Option 1 -----------------------------
for f in $ext
do
if grep -l $input $f; then
echo $f;
fi
done
# Option 2 ------------------------------
grep -r $input $ext | cut -d: -f1
@duyet
Copy link
Author

duyet commented Mar 15, 2015

Using Option 1 or Option 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment