Fedora Linux Support Community & Resources Center
Old 18th April 2006, 08:59 PM
thesource Offline
Registered User
Join Date: Mar 2005
Posts: 83
Question Scripting help

hello all-

I need some help writing a script.

I would like to script to

1. perform a search for file name with exension
2. rename the folder two levels up with the file name found


for file in (find -name *.cat ); do
mv .. $filename.

The only problem is that the output of the find wants to name the .. folder the whole path of *.cat



How do I tell it to only use "myfile.cat" to rename the granpa directory .. ?

Can I use sed to extract myfile.cat and pipe that output into another command?

confused here?
Reply With Quote
Old 18th April 2006, 09:49 PM
ezzetabi Offline
Registered User
Join Date: Mar 2006
Location: assert(false);
Posts: 111
do not try it as root...
A=`find "$FOLDER" -iname '*.'"$EXT"`
for i in $A
  DIRNAME=`dirname "$i"` #dirname of the file
  FILENAME=`basename "$i"` #filename and dest of renaming
  cd "$DIRNAME"/../..
  CF=`dirname "$PWD"` #folder that keeps the folder we'll rename

  mv "$PWD" "$CF"/"$FILENAME" #renaming

cd "$AF"

Last edited by ezzetabi; 18th April 2006 at 09:51 PM.
Reply With Quote
Old 18th April 2006, 10:40 PM
Firewing1 Offline
Registered User
Join Date: Dec 2004
Location: Canada
Age: 26
Posts: 9,224
ls -l | awk '{printf $9"\n"}' | grep \.ext$
will list all files ending in ext... Does that help?
[+] My open source software and blog
[+] Some of my howtos: (for full list, click here)
Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting help boknoy Using Fedora 3 3rd August 2007 02:44 PM
Scripting Help! KoubaK Linux Chat 2 28th April 2007 05:45 AM
help with scripting mitchell2345 Using Fedora 2 28th February 2007 02:08 AM
Scripting help mitchell2345 Using Fedora 5 23rd January 2007 08:06 AM
cron scripting/bash scripting coolbeansdude51 Using Fedora 7 16th January 2007 04:13 AM

Current GMT-time: 09:22 (Saturday, 23-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat