Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Aug 2005 03:08:35 -0700 (PDT)
From:      Ceasar Navato <jhongjr@yahoo.com>
To:        Brian John <brianjohn@fusemail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: moving everything except a directory
Message-ID:  <20050831100835.5670.qmail@web60819.mail.yahoo.com>
In-Reply-To: <433DBEC0.1030001@fusemail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


--- Brian John <brianjohn@fusemail.com> wrote:

> Say I am at ~ and I have 10 directories inside named
> 1, 2, 3, 4 ,5, 6, 
> 7, 8, 9 and 10.  What command can I use to move
> everything but directory 
> 2?  
You can use combination of different commands to solve
this problem.

Base on your problem, you can move all directories
excetp 2.
mv `ls -l | grep -v 2 | awk -F " " '{print $9}'` 
<destination directory>

Take note that the above commands do not only move the
directories and its contents but also all the files in
the current directory. If this is what you want, then
the above commands will do it.

What if I wanted to move everything but
> directories 2 and 7?

Just pipe another command,e.g. "grep -v 7", after the
first grep command.

Another option is to write a script if you want 
> 
> I'm not sure how to use the mv command to do this in
> 1 comand.
> 
> Thanks
> 
> /Brian
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
>
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe@freebsd.org"
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050831100835.5670.qmail>