Linked Questions
10 questions linked to/from difference between "function foo() {}" and "foo() {}"
2
votes
1
answer
1k
views
Difference between writing `function Name { ...; }`, `Name () { ...; }` and `function Name () { ...; }` in bash [duplicate]
You can write a bash functions several ways:
function JoinStrings {
...;
}
Or
function JoinStrings () {
...;
}
Or
JoinStrings () {
...;
}
Is there any difference between these functions?...
1
vote
0
answers
164
views
FuncName(){} vs function FuncName() {} [duplicate]
There is two ways to define function in bash script.
1.
function FuncName() {
echo "$FUNCNAME"
}
2.
FuncName() {
echo "$FUNCNAME"
}
So my questions is what's the different between in this ...
181
votes
11
answers
421k
views
How to run grep with multiple AND patterns?
I would like to get the multi pattern match with implicit AND between patterns, i.e. equivalent to running several greps in a sequence:
grep pattern1 | grep pattern2 | ...
So how to convert it to ...
27
votes
8
answers
17k
views
Linux shell script: Run a program only if it exists, ignore it if it does not exist
I am programming a Linux shell script that will print status banners during its execution only if the proper tool, say figlet, is installed (this is: reachable on system path).
Example:
#!/usr/bin/...
5
votes
2
answers
17k
views
shell script error : Syntax error: "(" unexpected
I have checked the previous post on this error. still did not get the solution working. Here is my bash script. can some one help me figure out the issue . I have used https://www.shellcheck.net/ to ...
3
votes
3
answers
14k
views
How to call a shell function
How can I use the integer value returned by a function in shell script that takes some arguments as input?
I am using the following code:
fun()
{
echo "hello ${1}"
return 1
}
a= fun 2
echo $...
-1
votes
1
answer
2k
views
Automatically export shell/bash functions
I have a bash function declared like so:
function foo {
echo "this is foo";
}
I didn't call export -f foo, but it still was available in subshells.
However, typically when I declare a function ...
1
vote
2
answers
1k
views
`rm` prompt when given more than one file [duplicate]
For some reason, my finger memory has converted mv to rm. Until I manage to retrain those fingers, how might I have rm prompt when provided multiple locations (one of which likely does not exist)?
I ...
0
votes
1
answer
195
views
What is the intended purpose of the () syntax in a bash function?
I am freshening up my bash skills. I use the term skills very loosely; I've been outta the game a long time. So, as a way to brush up, I decided to code something utilizing bash/zenity/yad. I read man ...
-1
votes
1
answer
139
views
Version Update from 14.04.3 LTS to 16.04.2 LTS
I have recently Updated from 14.04.3 LTS to 16.04.2 LTS. My shell scipts that got executed on 14 version are failing in the latest version i.e. 16.04.2.
Below are the sample errors:
test: 24: test: ...