PDA

View Full Version : How to make shell script ask input



Fli
09-21-2013, 02:29 PM
Hello,

i always forget right syntax or im lazy to write commands like:

find . -type f -exec grep -i SEARCHPHRASSEHERE '{}' \; -print

so i would like to ask how to do shell script, which will upon execution ask me to enter search prasse.

like in command line i type: search. and it will run this script and ask me for search phrasse.

Or i will type search/ and it will run another script which will be searching whole filesystem.

how such script which will run such command and ask user to input search phrasse look like and how to execute it by typing special command from commandline from any directory?


-----------------
some ideas:

#!/bin/bash
read -p "Type the search querry here:" querry;
find . -type f -exec grep -i $querry'{}' \; -print

---

#!/bin/bash
echo -n "Type the search query here: "read query
grep -lri "$query" .