Skip to content

Instantly share code, notes, and snippets.

@mattravenhall
Last active December 30, 2017 10:37
Show Gist options
  • Select an option

  • Save mattravenhall/cd9c9019f1a981ee13917885c0e414e3 to your computer and use it in GitHub Desktop.

Select an option

Save mattravenhall/cd9c9019f1a981ee13917885c0e414e3 to your computer and use it in GitHub Desktop.
Multiple on-demand grep searches can be tedious, this short script allows user inputs to substitute grep search commands for a specific file.
input=''
if [ "$1" = '' ]; then
input='quit'
echo "Please provide file to search as 'grepWrapper.sh <fileToSearch>'"
fi
while [ "${input}" != 'quit' ]; do
echo "Please provide search sequence, or 'quit':"
read input
grep ${input} $1
echo ''
done
@mattravenhall
Copy link
Author

mattravenhall commented Dec 29, 2017

The key take-home here is the 'read' command, this principal can be applied to any number of commands. Call as: grepWrapper.sh

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