[SOLVED] Mv command giving unexpected fault

Quick to answer questions about finding your way around Linux Mint equally a new user.

Forum rules
At that place are no such things as "stupid" questions. Notwithstanding if you think your question is a bit stupid, then this is the right place for you to post information technology. Please stick to easy to-the-signal questions that y'all experience people can answer fast. For long and complicated questions prefer the other forums inside the support section.
Before you post please read how to go help

Tyberion
Level 1
Level 1
Posts: viii
Joined: Mon Feb 19, 2018 eight:22 am

[SOLVED] Mv control giving unexpected fault

Hey all, maybe yous can help me with something I'grand scratching my head about. I am trying to employ wildcards to move a group of files and am getting this result:

Code: Select all

                  $ mv *unsorted* Unsorted/ mv: invalid selection -- 'Due north' Try 'mv --help' for more information.                                  

mv --assist confirms there is no 'N' option, which doesn't assistance, and a Google search confirms my syntax "should" be working.

Any idea what'due south up? Thanks!

Last edited by Tyberion on Tue Feb 20, 2018 seven:31 am, edited 1 time in total.

User avatar

austin.texas
Level xx
Level 20
Posts: 12004
Joined: Tue November 17, 2009 iii:57 pm
Location: at /home

Re: Mv control giving unexpected error

Post by austin.texas »

Works for me with no error... :shock:

Code: Select all

                  dan@skynet1 ~/Documents $ mv *test* ~/Desktop/ dan@skynet1 ~/Documents $ cd .. dan@skynet1 ~ $ ls Desktop reservations.html  test1.txt  test2.txt                                  

I don't know what could cause the error.

Mint eighteen.ii Cinnamon, Quad core AMD A8-3870 with Radeon HD Graphics 6550D, 8GB DDR3, Ralink RT2561/RT61 802.11g PCI
Linux Linx 2018

Mute Ant
Level 14
Level 14
Posts: 5115
Joined: Tue Sep 03, 2013 7:45 pm
Location: Norfolk U.k.

Re: Mv command giving unexpected error

Mail service by Mute Pismire »

I bet one of the names that matches... *unsorted* ...starts with... -Northward ...and the mv control sees it equally options in the middle of the list. Avoiding names that start with '-' becomes a habit. They invented -- for this instance, to signal NoMoreOptions...

bear upon -Nobbly ### Fails with touch: invalid selection -- 'N'

touch -- -Nobbly ### OK... except now you lot have a file name that starts with a '-'

rm -Nobbly ### Fails with rm: invalid option -- 'N'

rm -- -Nobbly ### OK

While you're waiting, read the free novel we sent you. It's a Castilian story about a guy named "transmission".

rene
Level 19
Level 19
Posts: 9641
Joined: Sun Mar 27, 2016 6:58 pm

Re: Mv command giving unexpected error

Post by rene »

Mute Ant wrote: ↑

Mon February 19, 2018 11:59 am

I bet 1 of the names that matches... *unsorted* ...starts with... -N

And to affiche, note that this is as such fundamentally a consequence of the shell performing wildcard expansion in UNIX: i.e., not mv being daft enough to expand a wildcard into what it itself thinks is an pick, but the shell simply feeding the complete expansion to mv, -North and all.

jglen490
Level 5
Level 5
Posts: 998
Joined: Sat Jul xv, 2017 9:57 pm

Re: Mv command giving unexpected fault

Post by jglen490 »

Does the directory - Unsorted/ - be in your Path?

I feel more like I do than I did when I got here.
Toshiba A135-S2386, Intel T2080, ATI Radeon® Xpress 200M Chipset, 2GB RAM, 500GB

User avatar

Flemur
Level twenty
Level 20
Posts: 10117
Joined: Mon Aug 20, 2012 ix:41 pm
Location: Potemkin Village

Re: Mv command giving unexpected error

Mail by Flemur »

Tyberion wrote: ↑

Mon February 19, 2018 8:31 am

mv *unsorted* Unsorted/

Please edit your original postal service title to include [SOLVED] if/when it is solved!
Your data and OS are backed upwards....right?

Tyberion
Level 1
Level 1
Posts: 8
Joined: Mon Feb 19, 2018 8:22 am

Re: Mv command giving unexpected fault

Mail by Tyberion »

Was happy to see and then many helpful replies after getting dwelling from work. Cheers so much everyone!

After I saw the suggestion that one of the file names might start with '-Due north' I searched (there are effectually 2000 files) and sure enough there were really a handful of them that had that. The specific one causing the trouble started with '-Nebula_Awards...' and so, there ya take it! Afterwards quickly renaming the offenders, a second later and all of my unsorted files were in the unsorted directory.

And so lesson learned, Bash will freak out if a file proper noun looks like a command argument. Thanks again everyone for your help! :)

Mute Ant
Level 14
Level 14
Posts: 5115
Joined: Tue Sep 03, 2013 7:45 pm
Location: Norfolk UK

Re: Mv command giving unexpected error

Postal service by Mute Emmet »

That was just a practice. You lot await until you become file names that end with spaces...
touch "weasel.mp3" "weasel.mp3 " "weasel.mp3 " ; ls -one
weasel.mp3
weasel.mp3
weasel.mp3
...argh argh argh.

While you're waiting, read the complimentary novel we sent you lot. It's a Spanish story about a guy named "manual".

User avatar

Termy
Level 8
Level 8
Posts: 2382
Joined: Mon Sep 04, 2017 viii:49 pm
Location: UK
Contact:

Re: Mv command giving unexpected error

Post past Termy »

Mute Ant wrote: ↑

Mon Feb 19, 2018 7:xv pm

That was merely a practice. You wait until you get file names that end with spaces...

Lol Aye, I've come across that a couple of times; very weird.

Confused? Here's a guide to these forums!
Psst... I'chiliad Terminalforlife on YouTube.