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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:39:32+00:00 2026-05-16T15:39:32+00:00

I wrote a small shell script based on an example I found here: https://bbs.archlinux.org/viewtopic.php?id=36305

  • 0

I wrote a small shell script based on an example I found here: https://bbs.archlinux.org/viewtopic.php?id=36305

it takes this:

bash-3.2$ ls
test 001  test 002  test 003  test 004

and turns it into:

bash-3.2$ ls
001  002  003  004  rename.sh

However it gives me this error (even though it works):

bash-3.2$ ./rename.sh
mv: missing destination file operand after `rename.sh'
Try `mv --help' for more information.
`test 001' -> `001'
`test 002' -> `002'
`test 003' -> `003'
`test 004' -> `004'

Though it works correctly, it would be nice to see where I messed up, I assumed by default it would put the files in the same directory (this is the desired output).

#!/bin/bash
ls | while read -r FILE
do
        mv -v "$FILE" `echo $FILE | awk -F ' ' '{print $2}'`
done

Thanks in advance for helping me correct my incorrect code.

  • 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-05-16T15:39:33+00:00Added an answer on May 16, 2026 at 3:39 pm

    Postman almost has it. For rename.sh, the awk command returns nothing so in effect you have the following command the shell attempts to execute:

    mv rename.sh
    

    hence the error message “missing destination file”

    you can fix this by testing for the filename of the script, either hardcoded or $0, and executing the mv command only if $FILE does equal the script name.

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

Sidebar

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My Spring MVC app is not allowing any logins and… May 17, 2026 at 2:24 am
  • Editorial Team
    Editorial Team added an answer Since the "API" will have to be accessible via normal… May 17, 2026 at 2:24 am
  • Editorial Team
    Editorial Team added an answer MATCHES will let you use regular expressions. May 17, 2026 at 2:24 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm currently trying to make some small shell-like utility for a custom script I
We have an existing java-based heavyweight project that needed an interactive script interpreter. After
I wrote a small app that turns out to be using a lot of
FastCGI servers, for example, impose an execution time limit on PHP scripts which cannot
I wrote a small application using iPhone 3.x sdk. The app works well on
I don't know if this actually belongs here, maybe this question is more suitable
i have a c problem can any one help me . i wrote a
In short: I want to generate two different source trees from the current one,
I am having problems with getting a HTML editor working. We are using contentEditable
I use cvs to maintain all my python snippets, notes, c, c++ code. As

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.