LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 05-15-2011, 01:57 PM   #16
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714

Quote:
Originally Posted by EricTRA View Post
meaning that if you run the command a second time a second .dir gets added which is not what he wants. I'm trying to figure out how to overcome that but haven't found a solution yet. Any ideas?

I already solved that: http://www.linuxquestions.org/questi...4/#post4357066
 
Old 05-15-2011, 02:03 PM   #17
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Hi,

Yes, I've noticed that but that wouldn't work if it were the first run. Say OP is running his tests in a testing environment to build a solution for his problem. After the first run .dir gets added, on the second run and the ones thereafter, if he does change the command between runs, he will not get .dir.dir and so on. But what if he wants to run this as a one command solution on another machine? Most likely OP just runs your commands to clean up his system so this doesn't apply but just thought it worth mentioning for completeness.

Kind regards,

Eric
 
1 members found this post helpful.
Old 05-15-2011, 02:06 PM   #18
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714
Quote:
Originally Posted by EricTRA View Post
But what if he wants to run this as a one command solution on another machine?
What difference will that make? It simply adds ".dir" if it's not there already.
 
Old 05-15-2011, 02:11 PM   #19
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Hi,

Sorry, didn't notice you've added the -not option. My brain is on Sunday mode. Should work correctly.

Kind regards,

Eric
 
1 members found this post helpful.
Old 05-25-2011, 11:15 AM   #20
sahil.jammu
Member
 
Registered: Jun 2008
Distribution: Ubuntu
Posts: 83

Original Poster
Rep: Reputation: 15
Hello Guys,

Came across another scenario, i'm struck at a point, Need your inputs to proceed further:-

------
1. Traverse entire file system, look for directories which has .git directory in it
2. Rename the immediate parent directory to <orignal_name.git>
3. Traverse this new file structure and look for all directories with <original_name>.git
4. cd to that directory and remove its contents
5. once everything inside the directory is deleted, create a file
------

Code:-
Step 1:- find * -type d -iname '.git'
Step 2:-
function rename_git_parent
{
for file in "$1"/*
do
cd .. | $(pwd) -exec mv '{}' '{}'.git ';'
done
return 1
}


//i am not too sure if its the right way of doing it, or shall i use dirname...


How shall i go about step2 and ownwards...
Appreciate the help.

Thanks.


Regards
Sahil
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sed and rename text in file cober Programming 2 02-10-2011 04:30 PM
How to rename a File System in Solaris 9 solarisnewbie Solaris / OpenSolaris 3 02-06-2009 09:34 AM
Directory Traverse & Rename Script fsckin Programming 3 10-05-2008 02:43 AM
bash: make rename script traverse directories morrolan Programming 2 11-08-2006 11:52 AM
Bash script to traverse directory tree and rename files intramaweb Programming 3 10-08-2006 01:51 PM


All times are GMT -5. The time now is 03:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration