Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1070345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:32:50+00:00 2026-05-16T20:32:50+00:00

I am trying to substitute output from variable to give another output. The variable

  • 0

I am trying to substitute output from variable to give another output. The variable i have problems with is the $apps. It gives me “syntax error: bad substitution”.

$appletDir is a directory with desktop shortcuts. The problem is that some shortcuts do not have the same name as the icon(png). So i need to substitute the program name with the png linking to it. I got it working with the commented out if-statement below. If this substitution could work then my script would look better. Cause i need to put down a couple of this.

I want it to look for “general_call” instead of “rtcom-call-ui” when going through the icon folders. Cause the png is called “general_call”. The icons folders are the variables $icoDir64 $icoDirSca.

for applet in $appletDir*
do

app=`basename $applet | sed -e 's/.*://g' -e 's/.*osso-//g' -e 's/\.desktop.*//g'`
apps="${app/rtcom-call-ui/general_call}"
    #if [ "${app}" = "rtcom-call-ui" ]; then
    #   app="general_call"
    #fi
#echo $apps
#done
#exit 0

found=`find ${icoDir64} ${icoDirSca} -name "*.png"`

for file in $found
do
    base="`basename ${file}`"

    if [ "${base}" = "${app}.png" -o "${base}" = "tasklaunch_${app}.png" -o "${base}" = "general_${app}.png" ]; then
        echo "WORKING!!!!!!!!!!!!!!!!!! $file" 
    fi
done
done
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:32:51+00:00Added an answer on May 16, 2026 at 8:32 pm

    I think you may have a shell version problem (your shell isn’t as modern as the notation you are using). A previous incarnation of this post suggested:

    apps="${app}/rtcom-call-ui/general_call"
    

    Or, for substituting rtcom-call-ui with general_call, you need to use echo and sed (at least in classic shells – it might be that bash has something built-in to do it):

    apps=$(echo "${app}" | sed s/rtcom-call-ui/general_call/)
    

    The notation ${var|continuation} (where | represents an arbitrary punctuation character) is used to modify the value substituted. For example:

    apps="${app:-/something/suitable/as/the/default}"
    

    would copy the value of $app, unless $app is not set at all (not relevant here; useful with environment variables) or if $app is an empty string.

    The error you are getting is because there is no valid substitution that starts with ‘/‘ in your version of the shell. This notation seems to be valid in some versions of Bash (including the one I have to play with); I don’t know when it was added. But if the shell you are using is complaining about the notation, then clearly it is not correct for the version of the shell you are using.

    Depending on the shebang line (#!/bin/sh vs #!/bin/bash), it might work differently. Failing that, the version of Bash on your machine may be too old.

    You can check your shell(s) with:

    for app in /some/location/rtcom-call-ui/where.png /another/location/nowhere/thing.png
    do
        apps=${app/rtcom-call-ui/general-call}
        echo $app
        echo $apps
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to copy the msdn refernce here doesn't work and gives an error I
I need some help in bison grammar construction. From my another question: I'm trying
I'm trying to substitute a string variable, containing multiple quoted words, as a parameter
I am trying to create a program which will substitute a character in place
trying to figure out why this is happening - I have an input text
Possible Duplicate: Substitute multiple whitespace with single whitespace in Python trying to figure out
I'm trying to write a program that manipulates unicode strings read in from a
I'm trying to remove a specific word from a certain string using the function
I am trying to substitute <br> to \n but do not find how use
I'm trying to test a WCF service without creating a WCF client. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.