I'm trying to write a find and cd function like so:
findcd () {
cd "$(dirname "$(find '$1' -type '$2' -name '$3')")"
}
to be called like so:
find . f [FILE_NAME]
But it's seeing the dollar sign and expecting more arguments as oppose to executing what's inside. I'm just starting with writing aliases and functions, so any advice would be super helpful!
$1
etc. are single-quoted and thus not expanded. Please see What is the difference between the "...", '...', $'...', and $"..." quotes in the shell? and the citation in the second "quirk" in this answer which explains why "nested" double-quotes will work for you. Your function will still fail iffind
finds more than one file.