[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Tackling parameter expansion in functions
From: |
Richard Taubo |
Subject: |
[Help-bash] Tackling parameter expansion in functions |
Date: |
Fri, 12 Feb 2016 12:56:22 +0100 |
Hi!
I'm trying to make a function, but when I pass it a parameter
I get an "illegal byte count" error.
I guess it's due to Parameter expansion.
What do I need to change to make the last example work?
# ================================================
# ----------------- This Works
----------------------------------------------------
Test() {
printf "my_word" | head -c${1:-7}
}
Test
# ----------------- Does not work ---------------------------------------
Test2() {
printf "$1" | head -c${1:-7}
}
Test2 "my_word"
# ================================================
Thanks! :-)
Best regards,
Richard Taubo
- [Help-bash] Tackling parameter expansion in functions,
Richard Taubo <=