Click here to Skip to main content
13,048,406 members (95,264 online)
Rate this:
Please Sign up or sign in to vote.
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

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

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 19-Feb-13 20:14pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100