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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:40:56+00:00 2026-06-14T18:40:56+00:00

hey so I have some code for the question bellow but I am stuck

  • 0

hey so I have some code for the question bellow but I am stuck its not working and I don’t really know what I am doing.

This script should remove the contents of the dustbin directory.
If the -a option is used the script should remove ALL files from the dustbin.
Otherwise, the script should display the filenames in the dustbin one by one and ask the user for confirmation that they should be deleted

#!/bin/sh

echo " The files in the dustbin are : "
ls ~/TAM/dustbin

read -p " Please enter -a to delete all files else you will be prompted to delete one    by one : " filename

read ans
if ["filename" == "-a"]
cat ~/TAM/dustbin
   rm -rf*
else
   ls > ~/TAM/dustbin
for line in `cat ~/TAM/dustbin`
do
   echo "Do you want to delete this file" $line
   echo "Y/N"
   read ans
   case "ans" in
      Y) rm $line ;;
      N) "" ;;
esac

EDITED VERSION

 if test ! -f ~/TAM/dustbin/*
then
echo "this directory is empty"
else
for resfile in ~/TAM/dustbin/*
do
   if test -f $resfile ; then
   echo "Do you want to delete $resfile"
   echo "Y/N"
   read ans
   if test $ans = Y ; then 
   rm $resfile
   echo "File $resfile was deleted"
   fi
   fi
done
fi

this works however Now I get one of 2 errors either

line 4 requires a binary operator or line 4: to many arguments

  • 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-14T18:40:58+00:00Added an answer on June 14, 2026 at 6:40 pm

    I see one obvious mistake:

    rm -rf*
    

    when it should be

    rm -rf *
    

    to be asked about every file deletion – add -i key

    rm -rfi *
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I have downloaded one of the xml editors from some site. But don't
Hey, i have some experience with MVC. but I'm new to rails. I'm using
Hey guys, I have some code that I found that I would rather use
Hey guys. I'm not much of a programmer, but still need to do some
Hey I Have some Problem to Find Exact Imotion(Facebook) for That Smily Code.. I
Hey all i have some CSS code like so: /* ROW 1 (1-8) */
Hey guys, It's 5 am here, I was doing some code... when this came
Hey I have been trying to work on this for some time but I
Hey, I have some text that is formatted like this: [quote]foo text[/quote] and I
Hey guys I simply cannot get this to work. I have some content that

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.