문제

market_l="${echo $1 | awk '{print tolower($0)}'}"
echo $market_l

when i execute this its giving me an error below:

./test: market_l="${echo $1 | awk '{print tolower($0)}'}": The specified substitution is not valid for this command.
도움이 되었습니까?

해결책

Did you mean to use the $() operator instead of ${}?

다른 팁

you should use $() to assign output to a variable. not ${}

market_l="$(echo $1 | awk '{print tolower($0)}')"

or you can do it with ksh

#!/bin/ksh
typeset -l market_l
market_l="$1"
echo $market_l

Other ways to change case besides awk, fyi

$ echo "$1"|tr [A-Z] [a-z]

$ echo "$1"|sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top