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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:39:44+00:00 2026-06-15T04:39:44+00:00

Hey I have the following code which checks if the file already exists in

  • 0

Hey I have the following code which checks if the file already exists in the location that it was originally in before it was removed.
This works and if it does not exist then it will be moved which also works,
But My question is how can I get the shell script to ask the user to specify a new name to rename the file to and then store it under the new name if a file with the same name exists already.
The code for the rename should go underneath the echo in the first part of the if

#! /bin/sh
#restore the dustbin contents 

if [[ -f "$(grep $1 /root/TAM/store) " ]]; then
   echo "A File with the same name already exists please rename this file to store it"
else 
   mv /root/TAM/dustbin/$1 `grep $1 /root/TAM/store`
   cd /root/TAM
   rm store
   touch store
fi

EDIT

read -p "please enter a new name:  " newName
mv /root/TAM/dustbin/$1 /root/TAM/dustbin/$newName
cd /root/TAM
rm store
touch store
  • 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-15T04:39:45+00:00Added an answer on June 15, 2026 at 4:39 am

    To prompt the user, try doing this :

    read -p "New name >>> " name
    echo "The file name is $name"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guy i have following problem: I have this line of code which includes
Hey I have the following code which I'm using to isolate the a b
Hey so I have the following code which should throw up the errors if
Hey guys I have the following code working which is sending a GET Request
Hey community I have the following ServerSocket which should listen to port 53000 and
Hey all, basically i have an empty AS3 fla file with just the following
Hey I have this code right here: http://pastie.org/534470 And on line 109 I get
Hey guys, I have the following HTML structure that I am trying to pull
I have written code such as the following, which by assumption shouldn't compile. I'm
Hey I have a snippet of assembly code that does not make sense to

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.