Just another idea to add to the already wide set of options from Serg's excellent answer.
You might be able to use an
alias for this - possibly with some slight changes to how you currently do things.
alias is simply a word that you choose to map to a larger string, which the shell will expand whenever it encounters it. Perhaps the most commonly seen use case is to apply 'defaults' to an existing command, like this:
alias ls='ls -a --color=auto'
However, there's no requirement that your
alias has to be named after an existing command - or even shorter than its destination pattern - so you could e.g.
alias tgzcreator='tar -czvf'
aliases share lifetime with the shell in which they are defined. 'Persistent'
aliases for you can be set up in
~/.bash_aliases, which should be sourced automatically by most well-written default
.bashrc scripts and suchlike.
Note a couple of hints:
- Rather than worrying in a particular script whether a previously defined
alias will interfere with your code, you can prefix it with a backslash to ensure
aliasing is skipped. e.g. I normally
cp -i to avoid accidentally overwriting things, but in some scripts, I clearly want to overwrite things. (I'm not going to use some awful workaround like setting up a known un
aliased user!) So, in that script, I'll use
\cp src dst
aliases may not be sourced by default within shell scripts, which launch their own non-interactive copy of the shell. You can ensure they are expanded by setting the option
expand_aliases in your script. I got this from: https://stackoverflow.com/questions/2197461/how-to-set-an-alias-inside-a-bash-shell-script-so-that-is-it-visible-from-the-ou
So, basing off the limited context available in your post, you might want to do something kinda like this:
shopt -s expand_aliases
alias get_etc_dir='find /etc -type d'
alias get_etc_fil='find /etc -type f'
For you, this may not work without tweaking, e.g. changing your parameterised inode type into a per-alias suffix. It's just another option for how users can shorten bits of code in general. Either way, I've tried to explain comprehensively based on what I know, and I hope it's useful somewhere.
(Also, I'd suggest moving this to Unix/Linux SE, assuming that's the ideal for things that aren't Ubuntu-specific?)