How to Move Directory With Spaces In Between?

Sun sparc / Sparc 9
July 20, 2009 at 23:57:18
Specs: Solaris 5.8, 2GB
I am facing a problem which is Driving me Nuts.
Here we are given Patches/Hotfixes which are Developed by Developers on Windows, which we Load
on Solaris using SecureFTP or some other Tool.
The Nomenclature that they follow is Like this:-
"DD-MON-YYYY v AA.BB" where AA=Version and
BB=Patch Number. As you might have noticed, On Either Side of "v" there is a space.
So the directories are something like this:-
[root@bsnlom01 patches]# ls -1|sort -t\. -n -k2,2|grep -v BACKUP|head -10|tail -9
09-Mar-2009 v 0.1
10-Mar-2009 v 0.2
16-Mar-2009 v 0.3
19-Mar-2009 v 0.4
26-Mar-2009 v 0.5
27-Mar-2009 v 0.6
30-Mar-2009 v 0.7
31-Mar-2009 v 0.8
01-Apr-2009 v 0.9

Note all these are Directories. There are 153 Such Directories and Still Counting. I want to MOVE all these Old Directories to an Archive Directory, but unable to do so because of Space In Directory Name.
I tried following:-
ls -1|sort -t\. -n -k2,2|grep -v BACKUP|while read line
mv -i $line WOM_Hotfixes;
But its failing as it is trying to read all three sections as separate directories.

Please help me out with this Issue.
Thanks In Advance,

See More: How to Move Directory With Spaces In Between?

Report •

July 21, 2009 at 00:07:01
Hi Friends,

I got the solution, but thought will Post here for others.
Simply Quote the String with Double Inverted Commas("").
As simple as that. :-)
So script would be:-
ls -1|sort -t\. -n -k2,2|grep -v BACKUP|grep -v WOM|while read line
mv -i "$line" WOM_Hotfixes
And Bingo, all those files are moved to Archive Dir "WOM_Hotfixes".

Cheers :-)

Report •
Related Solutions

Ask Question