Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2006
    Posts
    1

    Exclamation Unanswered: 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

  2. #2
    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 05:04.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •