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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:07:22+00:00 2026-06-14T20:07:22+00:00

Thank you in advance for any help, this is coursework so further reading/ pointers

  • 0

Thank you in advance for any help, this is coursework so further reading/ pointers is greatly appreciated.

I asked a question the other day relating to my own delete/trash/restore scripts and I have completed delete and trash as well as giving delete a backup text file for Restore to use later on.

However, instead of giving me errors, the Restore script just kinda stops in the console. Like when I type # ~/Restore -n the cursor skips to the next line without the usual # and I have to close it manually. Likewise without the -n option. The -n option should ask for a new location to restore to, and without it should restore to the files original location.
I’ll post my script, see what y’all think.

#!/bin/bash
if [ "$1" == "-n" ]
then  cd ~/rubbish
  restore= grep $2 ~/store      
  filename= basename "$restore"
  echo "Type the files new location"
  read location
  location1 = "readlink -f $location"       
  mv -i $filename "$location1" /$filename       
else  cd ~/rubbish          
  restore= grep $2 ~/store      
  filename= basename "$restore"         
  mv -i $filename "$location1" $location            
fi

so, ~/rubbish is my own created directory to act as a recycle bin and ~/store is my text file which appends the deleted files readlink details on deletion. I can post the whole 3 scripts if necessary?

Many thanks!

  • 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-14T20:07:23+00:00Added an answer on June 14, 2026 at 8:07 pm

    If you call ~/Restore -n it will go to the if part and do a grep $2 ~/store. Since there is no parameter $2 it will result in grep ~/store, which tells grep to search for “~/store” in the input coming from standard input.

    That’s why your script stops and waits for input.

    You can either test for a second parameter or enclose $2 in double quotes to make sure grep gets the correct number of parameters. Better yet, do both: 1. test for a second parameter and 2. enclose $2 in double quotes.

    Some more points:

    • Don’t put spaces around =
    • enclose commands in backticks `, if you want to capture the output
    • And no spaces between directory and filename

    So, you should presumably write

    restore=`grep "$2" ~/store`
    filename=`basename "$restore"`
    echo "Type the files new location"
    read location
    location1=`readlink -f "$location"`
    mv -i $filename "$location1/$filename"
    

    I suggest you look at bash info and follow the “Books and Resources”.

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

Sidebar

Related Questions

Good evening fellow coders, and thank you in advance for any help/attention. This is
Thank you in advance for any help with this problem. The Problem: Using Jquery
Thanks in advance for any help you can provide on this issue! I manage
Thanks for any help in advance, I can't wrap my SQL skills around this
i have very serious problem if any tech expert can help...thank you in advance..
First I would like to thank in you in advance for any help in
I'm new to actionscript 3, So Thank you in advance for any help you
Thank you in advance for any help. I have a website which has OpenGraph
Thank you in advance for any help you can give. I am implementing sprites
Thank you in advance for any help, I have been pulling my hair out

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.