Changes

Jump to navigation Jump to search
375 bytes added ,  07:59, 30 January 2020
Line 30: Line 30:  
In bash functions, $1 server as the first bash function parameter and so on.  
 
In bash functions, $1 server as the first bash function parameter and so on.  
 
===Example===
 
===Example===
 +
<syntaxhighlight lang="bash" >
 +
#!/bin/bash
 +
die(){
 +
local m="$1"  # the first arg
 +
local e=$2    # the second arg
 +
echo "$m"
 +
exit $e
 +
}
    +
# if not enough args displayed, display an error and die
 +
[ $# -eq 0 ] && die "Usage: $0 filename" 1
 +
 +
# Rest of script goes here
 +
echo "We can start working the script..."
 +
</syntaxhighlight>
 
Another example:
 
Another example:
 
+
<syntaxhighlight lang="bash" >
 
fingerprints() {
 
fingerprints() {
 
         local file="$1"
 
         local file="$1"
Line 39: Line 53:  
         done < $file
 
         done < $file
 
}
 
}
 +
</syntaxhighlight>

Navigation menu