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

  • SEARCH
  • Home
  • 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 7619523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:42:30+00:00 2026-05-31T03:42:30+00:00

#!/bin/bash file=debian.deb test=basename $file .deb DP=blah/blah/$test/$test.php read -p [$DP]: DPREPLY DPREPLY=${DPREPLY:-$DP} echo Blah is

  • 0
#!/bin/bash
file=debian.deb
test=basename $file .deb
DP="blah/blah/$test/$test.php"
read -p "[$DP]: " DPREPLY
DPREPLY=${DPREPLY:-$DP}
echo "Blah is set to $DPREPLY"
echo $DPREPLY>>testfile

So what I’m trying to do is set the variable test from the variable file and use it in the file testfile.

  • 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-31T03:42:32+00:00Added an answer on May 31, 2026 at 3:42 am

    Use the command substitution $(...) mechanism:

    test=$(basename "$file" .deb)
    

    You can also use backquotes, but these are not recommended in modern scripts (mainly because they don’t nest as well as the $(...) notation).

    test=`basename "$file" .deb`
    

    You need to know about backquotes in order to interpret other people’s scripts; you shouldn’t be using them in your own.

    Note the use of quotes around "$file"; this ensures that spaces in filenames are handled correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/bin/bash -x echo Enter file name: read fileName fileName=`pwd`/$fileName if [ -f $fileName ];
#!/bin/bash echo SCRIPT: $0 echo Enter Customer Order Ref (e.g. 100018) read P_CUST_ORDER_REF echo
#!/bin/bash if test $# == 4; then echo $*; else echo args-error >&2; fi;
Hopefully this should be a simple one... Here is my test.sh file: #!/bin/bash patch_file=/home/my
I have this simple script: #!/bin/bash cmd=file.txt while read line do command $line >
So I have the following script (just a test) #!/bin/bash for file in *
I have the following files: ~/tmp/testbash$ l file 1.test move.sh* where move.sh is: #!/bin/bash
My bash script call a php file #!/bin/bash data=$(./getconfig.php) The file getconfig.php is: #!/usr/bin/env
following is the bash script I wrote for Sqlite. #!/bin/bash sqlite3 file.db CREATE TABLE
I have a shell script file (run.sh) that contains the following: #!/bin/bash %JAVA_HOME%/bin/java -jar

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.