27 lines
500 B
Bash
27 lines
500 B
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
#-------------------------------------------------------------------------------
|
||
|
|
# Example 2 for Bash Tips show 20: simple use of positional parameters
|
||
|
|
#-------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
#
|
||
|
|
# This script needs 2 arguments
|
||
|
|
#
|
||
|
|
if [[ $# -ne 2 ]]; then
|
||
|
|
echo "Usage: $0 word count"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
word=$1
|
||
|
|
count=$2
|
||
|
|
|
||
|
|
#
|
||
|
|
# Repeat the 'word' 'count' times on the same line
|
||
|
|
#
|
||
|
|
for (( i = 1; i <= count; i++ )); do
|
||
|
|
echo -n "$word"
|
||
|
|
done
|
||
|
|
echo
|
||
|
|
|
||
|
|
exit
|