If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Help!! bash shell scripting..

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-07-06, 12:47
Fr0z3n999 Fr0z3n999 is offline
Registered User
 
Join Date: Dec 2006
Posts: 1
Exclamation Help!! bash shell scripting..

Can any1 please help me...

i'm really lost in using bash shell scripting...

and i got to hand this up on monday...

please anyone teach me how to do this assignment...

Please use basic things because i just learn the program only... thanks

================================================== ===
Main

The script should provide feedback to the user on what is happening. Everytime a reference is modified, the script should display:
Replaced <original reference> with <modified reference>.

and you got to save another copy of the file.
example like: you have a 1.shk, after working on it... you can "auto" save (Don't need user to select yes or no) the file to 1_modified.shk
then once the script has finished reading the source file, it should also display how many references were modified. For example:
A total of 3 references have been changed.

if you were to use sed to replace some word containing “C:\\temp\\project” in the shake file how can you make it replace those with “C:/temp/project”, “C:\\\\temp\\\\project” and even “C:/temp\\\\project”.??
================================================== ===

I know this is too much... but can any kind soul help me here... i'm really in deep shit.... thanks... if you really don't understand... please msn me.. need to hand up by monday...

msn: frozen_boy_87@hotmail.com
Reply With Quote
  #2 (permalink)  
Old 12-08-06, 03:56
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Hi,

Substitutions like yours can be done with sed in the following ways. The patternseparating slashes can be replaced by any other character (in this case the pound sign) but this is for clarity purposes only; it doesn't take away the special meaning of the metacharacters in the pattern.
Code:
echo "C:\\temp\\project" | sed 's#\\#\/#g'
echo "C:\\temp\\project" | sed 's#\\#\\\\\\\\#g'
and in combination:
echo "C:\\temp\\project" | sed -e 's#\\#\/#' -e 's#\\#\\\\\\\\#'

Note that in the last example the 'g' as global qualifier is omitted in the 
expressions to substitute the first occurrence of '\\' with '/' only 
and make the second expression substitute the next occurrence with
'\\\\'. No other substitutions are made in this case.
Regards

Last edited by Tyveleyn; 12-08-06 at 04:04.
Reply With Quote
Reply

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On