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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:10:19+00:00 2026-06-14T23:10:19+00:00

I am about as new to bash scripts as it gets, so probably quite

  • 0

I am about as new to bash scripts as it gets, so probably quite the stupid question, but here it goes.
The idea is as follows: save basename of a file in a log–> move file–> use log to move back to original location.

basename $filename >> /directory/log
mv $filename /directory

So far so good, but I am quite confused as to how to use that log file to get file back. Is basename even the right thing to use? Idea I had was using grep to find filename in the log, but how do I go about getting that output at the end of mv ?

mv $filename ???

Am I on the right track? Screwing up something very basic?

  • 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-14T23:10:21+00:00Added an answer on June 14, 2026 at 11:10 pm

    Lets take the file httpd.conf as an example, it’s location is in directory /etc/httpd/conf/

    $ ls /etc/httpd/conf/httpd.conf
    /etc/httpd/conf/httpd.conf
    

    The command basename strips the path of the file and just returns the filename (and extension).

    $ basename /etc/httpd/conf/httpd.conf
    httpd.conf
    

    So when you do:

    basename $filename >> /directory/log
    

    You are creating a log file that contains only file names, you will not be able to use /directory/log to move the file back to it’s original location because you stripped that information with the basename command.

    You would want to do something like this:

    echo $filename >> /directory/log
    mv $filename /directory
    

    So that now /directory is the new location of the file and /directory/log contains the original location of the file.

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

Sidebar

Related Questions

I don't really know that much about bash scripts OR imagemagick, but I am
I have a general question about the new Django 1.3 static file framework. I
I found a great explanation about the new RTTI in Delphi ,but I don't
I am a bit confused about old/new so that's my question. What is the
I am new to Shell script. Just have a small question about some script
I'm really new with bash, but it's one of the subjects on school. One
I'm developer moving from C# to Java. Heard about new ASP net feature. <%:
Is there something new about row-level security in SQL Server 2012? In 2008 and
I heard about the new entity framework for .net, and decided to modify my
The team talks about one new effect released in jQUery UI 1.8. Which one

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.