You need to write either a shell script, as posted above, or a shell function, which is pretty much the same thing, except that it resides inside the current shell environment rather than a separate file.
To set it up as a function, put this in your .bashrc file.
Code:
fnd(){
find / -name "$1" -print
}
Once the terminal is restarted (or .bashrc reloaded), then "
fnd <searchterm>" should work (be sure to quote terms with spaces or other reserved characters).
You could even expand it to include the starting directory.
Code:
fnd(){
find "$1" -name "$2" -print
}
fnd "<startdir>" "<searchterm>"
As for the alias here:
Code:
alias fnd='sh test.sh'
This is not the correct way to launch the script. by specifying
sh as the interpreter in the alias you are telling it to ignore the original
/bin/bash shebang entirely. Better to just make it executable, and run it directly. Also don't forget that you need the full path to the script.
Code:
alias fnd='/path/to/script.sh'
Name the script properly, make it globally executable, and put it in a location in your PATH, and you can even skip the alias entirely.
As root, assuming /usr/local/bin is in your PATH:
Code:
mv test.sh /usr/local/bin/fnd
chmod a+x /usr/local/bin/fnd
PS: You need to double-quote the
$1 parameter too, as I did above, so that it can properly handle shell-reserved characters.