Skip to content

Instantly share code, notes, and snippets.

@romulets
Created November 7, 2017 17:58
Show Gist options
  • Save romulets/54c94ce0ac8dc7acc9eb6a4ef3427b90 to your computer and use it in GitHub Desktop.
Save romulets/54c94ce0ac8dc7acc9eb6a4ef3427b90 to your computer and use it in GitHub Desktop.
List Grep: Show all occurrences of your search in a path
#!/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