All Questions
10 questions
0
votes
2
answers
358
views
Are functions equivalent to built in commands in the bash / shell scripting language?
Example
$ echo "This is great"
This is great
$ num2=2
$ num3="Three"
$ echo $num2
2
$ echo $num3
Three
Redefining echo:
$ echo(){ command echo "The command was redefined"; }
$ echo $num2
The command ...
1
vote
2
answers
438
views
Forbid use of specific commands
I develop tools on a cluster. Each user loads common environment files in their .bash_profile. I have a login node on which certain tools should not run. How can I prevent users from using those tools ...
2
votes
2
answers
138
views
How do I reference an original command, so I can replace it with a function
So I am trying to create a simple function to replace the standard who command with my own, similar to a function I use to replace the standard cd command.
Goal: Replace original who command with who ...
1
vote
3
answers
642
views
What is the reason for having numbers within the brackets of a function ? [duplicate]
I have seen on many occasions a name of a function (frankly speaking I just call it function because of it typical appearance, they are though sometimes named commands or system calls but I do not ...
2
votes
1
answer
75
views
Sort packages by size one-liner as function
While surfing web I've discovered nice one-liner that suits my needs well
expac -s "%-30n %m" | sort -hk 2 | awk '{print $1, $2/1024/1024}' | column -t|
However all the functional needed I got used ...
1
vote
2
answers
94
views
Install-on-Demand Wrapper Function for Executables
How do I make the following function work correctly
# Install git on demand
function git()
{
if ! type git &> /dev/null; then sudo $APT install git; fi
git $*;
}
by making git $* call /...
23
votes
1
answer
33k
views
Execute command supplied by function parameters
I'm trying to create a function method in a bash script that executes a command which is supplied to the method by the paramters.
Meaning somethings like this:
special_execute()
{
# Some code
...
4
votes
2
answers
2k
views
Best way to call command within a shell function having the same name [duplicate]
I like to encapsulate commands within shell-functions using the same name. But to avoid the shell-function calling itself recursively, I specify the complete path of the command as the following ...
11
votes
5
answers
4k
views
What are commands to find shell keywords, built in functions and user defined functions?
I was discussing with my friend on how the commands are parsed in the shell, and he told me that bash searches the command in following order
List of aliases
List of shell keywords
List of user ...
3
votes
3
answers
614
views
What does the "(8)" in fsck(8) mean? [duplicate]
*nix commands (and functions?) have a number with them, like fsck(8), killall(1), etc.
What does the number mean?