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 8341929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:37:36+00:00 2026-06-09T05:37:36+00:00

#!/bin/bash #trash.sh $TRASHDIR=$HOME/trash #Does not exist yet, i have loops further in #the script

  • 0
#!/bin/bash
#trash.sh

$TRASHDIR=$HOME/trash 
#Does not exist yet, i have loops further in 
#the script to check if the dir exists and to create it if not
echo $TRASHDIR
#I have ommited the rest of the script, 
#because this is where I have the problem

Let’s run this:

./trash.sh  
./trash.sh: line 3: =/home/someuser/trash: No such file or directory

How can I store this filename in a variable without bash evaluating it? Also: How do I use this variable later for tests?

if [ -e $TRASHDIR ]
then
  echo stuff here
fi
  • 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-06-09T05:37:37+00:00Added an answer on June 9, 2026 at 5:37 am

    Leave the initial $ character off when you define a var:

    TRASHDIR=$HOME/trash
    

    When you use $TRASHDIR, bash evaluates that as the empty string (or something else if was set previously), which is why it looks like:

    =/home/someuser/trash
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a really weird problem with /bin/bash and a script that uses printf
I have a bash-script (let's call it /usr/bin/bosh ) using the following she-bang line:
This is my bash script: #!/usr/local/bin/bash -x touch /usr/local/p touch /usr/local/rec DATA_FULL=`date +%Y.%m.%d.%H` CHECK=`netstat
#/bin/bash PATH_GSUTIL= [ -f $PATH_GSUTIL/gsutil ] || (echo $PATH_GSUTIL does not contain 'gsutil' &&
If I have a Bash script like: #!/bin/bash f() { # echo function name,
I have a bash script that looks like the following: #!/bin/bash FILES=public_html/*.php # */
I have this bash script here #!/bin/bash find /Users/ -name *.mov -o -name *.flv
I have a bash script mysql_cron.sh that runs mysqldump #!/bin/bash /usr/local/mysql/bin/mysqldump -ujoe -ppassword >
#!/bin/bash for((i=1;i <=10;i++)) do php /var/www/get.php done I have the above shell script that
I have a bash script: #!/bin/bash JAVA_VERSION=1.6.0_17 _STDOUT=`java -version` if [ $JAVA_VERSION = $_STDOUT

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.