April 2018
Beginner
284 pages
7h 3m
English
#!/bin/bash
myfunc() {
arr=$1
echo "The array: ${arr[*]}"
}
my_arr=(1 2 3)
myfunc ${my_arr[*]}
#!/bin/bash
myvar=50
myfunc() {
myvar=100
}
echo $myvar
myfunc
clean_file {
is_file "$1"
BEFORE=$(wc -l "$1")
echo "The file $1 starts with $BEFORE"
sed -i.bak '/^\s*#/d;/^$/d' "$1"
AFTER=$(wc -l "$1")
echo "The file $1 is now $AFTER"
}
#!/bin/bash myfunc() { arr=$@ echo "The array from inside the function: ${arr[*]}" } test_arr=(1 2 3) echo "The origianl array is: ${test_arr[*]}" myfunc (${test_arr[*]}) ...