Register
It is currently Sat Nov 01, 2014 5:05 am

Script for replacing of files


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sat Jan 07, 2012 2:19 pm   

Joined: Sat Jan 07, 2012 1:49 pm
Posts: 1
Hallo,
I am very new in the bashscripting and this is my first post in that forum.
I want to ask if someone can help me with script for the following.

The script must can to create modified copyes of files. Please create a few files with different extensions (example: .txt, .dat) in a folder to test the functionality of the script.
Syntax of the script: replace.sh <oldextension> <newextension> <pattern> <replacing>
All the files in the current directory, wich are having the same extension as from transfered parameter
and also the transfered <pattern> String containts, a new copy with the new extention create. The <pattern>string must be replaced with <replacing>.

Sorry for unprecisions in the text, but i am translating it from german.

Thanks!


Top
 Profile  
 PostPosted: Tue Jan 17, 2012 10:06 pm   

Joined: Tue Jan 17, 2012 7:38 pm
Posts: 1
Sounds interresting ...
replace.sh <oldextension> <newextension> <pattern> <replacing>
Means:
replace.sh .txt .sh stuff_* new_stuff_* ???

So you could also say:
replace.sh <oldpattern> <newpattern>
Right?
This will replace a whatever.txt to whatnew.sh

I have a similar script here. With a few modification it coud do the trick.
Do you need some kind of menu or fallback if the user didn't enter a <newpattern>?

EDIT:
Its done (mostly)!
Check the usage of this thing. You could do this a smarter way, but here you get the possibility to undo you changes (not really implemented).
At the moment you have to check the generated list which contains the cp stuff.
As always BEWARE of recursive settings ...

Maybe i do some undo stuff ... but atm im a byte out of time )=

EDIT2:
Check here for updates of this one:
http://pastebin.com/u/yokmp

EDIT3:
Like spamming, but:
Ive made a stupid mistake so i removed the script. I may rewrite it later. Not much time left for this these days )=


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


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 post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP