Skip to main content

All Questions

Tagged with
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 ...
KeyC0de's user avatar
  • 143
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 ...
kaligne's user avatar
  • 906
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 ...
Sam's user avatar
  • 133
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 ...
Abdul Al Hazred's user avatar
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 ...
im_infamous's user avatar
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 /...
Nordlöw's user avatar
  • 185
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 ...
BrainStone's user avatar
  • 3,744
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 ...
oHo's user avatar
  • 1,338
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 ...
Forever Learner's user avatar
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?
user541686's user avatar
  • 3,163