-
-
Save romulets/54c94ce0ac8dc7acc9eb6a4ef3427b90 to your computer and use it in GitHub Desktop.
List Grep: Show all occurrences of your search in a path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: Rômulo Farias | |
# Year: 2017 | |
# Name: List Grep | |
# Description: show all occurrences of your search in a path | |
# Usage: lg [optional dir] searchString | |
# Installation: copy this file to /bin and give it execution permission | |
if [ $# -eq 0 ]; then | |
echo "This script must take at least 1 param" | |
exit | |
fi | |
if [ $# -eq 1 ]; then | |
ls -la | grep $1 | |
exit | |
fi | |
if ! [ -d $1 ]; then | |
echo "First param must be a directory" | |
exit | |
fi | |
ls -la $1 | grep $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment