Click here to Skip to main content
15,904,926 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing a USB tree based application on a Linux operating system for that I am converting one of the shell script to C++. But I am not that much experienced in shell script

I am confused in this script

C#
if [ $level -gt 0 ]; then
        port=$((${devpath##*[-.]} - 1))
    else
        port=0
    fi


Any one please explain me the meaning of this script in usb-devices script in linux. How I can write a C/C++ code to equivalent of this. i am stuck in this $((${devpath##*[-.]} - 1)) line of script


Any help will be appreciated...
Posted

1 solution

This is parameter substitution using pattern matching as described in the ksh man pages[^]. It's a while since I wrote scripts but it appears to be looking for a string of the form devpath followed by zero or more characters, followed by a hyphen or a dot. The resulting value is decremented by 1 before being set into the variable port.

Note: I'm not 100% certain of my analysis here, experimentation should help to clarify it.
 
Share this answer
 
Comments
Arun Kumar K S 20-Feb-13 23:13pm    
Many thanks that link helped me to solve the issue....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900