Hope that you continue believing that there are note supid questions, Iḿ newbie.
linux Mint 14 mate, 32 bits, installed on a pendrive.
I am trying to get the mac address fron ifconfig comand.
command--> mac=${(ifconfig wlan0 |grep HWaddr):38:19}
linux --> bash: ${(ifconfig wlan0 |grep HWaddr):38:19}: bad substitution
if I do it in two steps it works fine.
mint@mint ~ $ a=$(ifconfig wlan0 |grep HWaddr)
mint@mint ~ $ b=${a:38:19}
mint@mint ~ $ echo $b
xx.xx.xx.xx.xx.xx
I am sure that this question is a bit stupid, at least. But I can not find where the problem. I tested whit little variations and the problem is the same.
any help will be apreciated.
Jose
command line error with substrings "bad sustitution"
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
command line error with substrings "bad sustitution"
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: command line error with substrings "bad sustitution"
I can't remember all the bash syntax, so would just use sed to cut off the part of the line that you don't want. Result is the mac address.
Moved your topic here as perhaps the scripting wizards here will have an answer how to do this with the bash syntax
Code: Select all
mac=$(ifconfig eth0 | grep HWaddr | sed 's/.*HWaddr //')
Re: command line error with substrings "bad sustitution"
thanks a lot xenopeek,
this solves my problem, I did not tried to use sed because I ignore how to work with it.
I still ignore why the bash fails, but your solution is very nice! hopefully, someone will explain why the bash command is failing
thanks again.
this solves my problem, I did not tried to use sed because I ignore how to work with it.
I still ignore why the bash fails, but your solution is very nice! hopefully, someone will explain why the bash command is failing
thanks again.