Welcome to Coding : Sécurité Programmation Réseaux

Search   in  

 Create an Account Home | Submit News Your Account Content | Topics | Top 10  


Accueil
· Home
· Listing des Articles
· Top 10
· Repository des Exploits

Les sujets / parties
· C / C ++
· Visual Basic
· Asm
· Reseaux
· Java
· Securite
· Divers

Utile
· Listing des Articles

· Telecharger
· Le Forum
· Liens
· Proposer un article

Top20 des Downloads
· 1: Etude des reseaux generalites et protocoles
· 2: Cheval de troie en VB avec sources
· 3: Netcat 1.1
· 4: Keylogger
· 5: Etudes des reseaux hauts debits architectures et protocoles
· 6: Ecoute de port
· 7: Etude du Smart Spoofing
· 8: Win Packet Capture Utils
· 9: Tutorial on Traffic Interception on Switched Lan using ARP spoofing
· 10: Cours de C

User Info
Welcome, Anonymous
Nickname
Password
(Register)
Membership:
Latest: gold-os
New Today: 0
New Yesterday: 1
Overall: 2179

People Online:
Visitors: 39
Members: 0
Total: 39

  
Coding : Sécurité Programmation Réseaux: Forums

Coding :: View topic - find directories and rename the directories
 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

find directories and rename the directories

 
Post new topic   Reply to topic    Coding Forum Index -> Scripting
View previous topic :: View next topic  
Author Message
zhengquan
Guest





PostPosted: Thu May 15, 2008 8:10 am    Post subject: find directories and rename the directories Reply with quote

Hello,
I would like to find some directories and rename then.

I use

find . -type d -name 'tau_*'

to find directories starting with "tau_". I would like to change
the underscore to a hyphen in the directory names use -exec, but can
not figure out the syntax.

Thank you!

Regards,
Zhengquan
Back to top
zhengquan
Guest





PostPosted: Thu May 15, 2008 8:10 am    Post subject: Re: find directories and rename the directories Reply with quote

On May 14, 1:53 pm, zhengquan <zhang.zhengq...@gmail.com> wrote:
Quote:
Hello,
I would like to find some directories and rename then.

I use

find . -type d -name 'tau_*'

to find directories starting with "tau_". I would like to change
the underscore to a hyphen in the directory names use -exec, but can
not figure out the syntax.

Thank you!

Regards,
Zhengquan

And it seems to complicate the problem that there are tau_*
directories under some other tau_* directories...

Zhengquan
Back to top
mop2
Guest





PostPosted: Thu May 15, 2008 1:10 pm    Post subject: Re: find directories and rename the directories Reply with quote

zhengquan wrote:
Quote:
On May 14, 1:53 pm, zhengquan <zhang.zhengq...@gmail.com> wrote:
Hello,
I would like to find some directories and rename then.

I use

find . -type d -name 'tau_*'

to find directories starting with "tau_". I would like to change
the underscore to a hyphen in the directory names use -exec, but can
not figure out the syntax.

Thank you!

Regards,
Zhengquan

And it seems to complicate the problem that there are tau_*
directories under some other tau_* directories...

Zhengquan

You can see previously the output with the "echo", so:
find . -type d -name 'tau_*'|while read D;do echo mv -i $D ${D/
_/-};done
Back to top
pk
Guest





PostPosted: Thu May 15, 2008 11:10 pm    Post subject: Re: find directories and rename the directories Reply with quote

On Wednesday 14 May 2008 22:19, zhengquan wrote:

Quote:
find . -type d -name 'tau_*'

to find directories starting with "tau_". I would like to change
the underscore to a hyphen in the directory names use -exec, but can
not figure out the syntax.

Thank you!

Regards,
Zhengquan

And it seems to complicate the problem that there are tau_*
directories under some other tau_* directories...

If you can, consider using the "rename" program (available on most systems).

Otherwise, you can try this (with bash):

find . -depth -type d -name 'tau_*' -exec
sh -c 'b=$(basename "$1");d=$(dirname "$1");
nn=${b//_/-}; mv -- "$d/$b" "$d/$nn"' sh '{}' \;

But I suggest you run this before:

find . -depth -type d -name 'tau_*' -exec
sh -c 'b=$(basename "$1");d=$(dirname "$1");
nn=${b//_/-}; echo "would perform mv -- $d/$b $d/$nn"' sh '{}' \;

To see what the program would do. The run the real one above.

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Coding Forum Index -> Scripting All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.36 Seconds