Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

daily question

  • 20-05-2002 8:16pm
    #1
    Registered Users, Registered Users 2 Posts: 476 ✭✭


    pablo's using vi

    i've a document that need to be ammed and replace every instance of a string with another string


    [PHP]/home/pablo/www/beta.1/

    with

    /usr/local/psa/home/vhosts/pablo.com/httpdocs/

    [/php]

    this doesn't work in vi
    :s / "/home/pablo/www/beta.1/" / "/usr/local/psa/home/vhosts/pablo.com/httpdocs/"


    any ideas why ?


Comments

  • Registered Users, Registered Users 2 Posts: 476 ✭✭Pablo


    *bump

    does anyone use vi

    here is the code again on one line
    :s / "/home/pablo/www/beta.1/" / "/usr/local/psa/home/vhosts/pablo.com/httpdocs/"
    


  • Registered Users, Registered Users 2 Posts: 476 ✭✭Pablo


    [php]:%s /\/home\/pablo\/www\/beta.1\/ / \/usr\/local\/psa\/home\/vhosts\/pablo.com\/httpdocs//g[/php]


  • Registered Users, Registered Users 2 Posts: 4,484 ✭✭✭Gerry


    I think what you want is :
    1,$s/\/home\/pablo\/www\/beta.1\/  /\/usr\/local\/psa\/home\/vhosts\/pablo.com\/httpdocs\//g
    

    (The space in the middle shouldn't be there, but I can't get rid of it)
    The 1,$ tells vi what line numbers to start and finish on, and you have to backslash the url forward slashes to tell vi that they are not delimiters and should be ignored.


  • Registered Users, Registered Users 2 Posts: 476 ✭✭Pablo


    thanks gerry
    i got it eventually , i used

    :%s/\/home\/pablo\/www\/beta.1\// \/usr\/local\/psa\/home\/vhosts\/pablo.com\/httpdocs\//g
    the % does it for the whole file /

    merci buckets

    there is a problem the way that the \/ are done with the [code] tag


  • Registered Users, Registered Users 2 Posts: 1,862 ✭✭✭flamegrill


    Actually i beg to differ, the "g" at the end is what does it for the whole file. its a regex standard from perl aswell and it means globally funnily enough.

    Regards,

    Paul


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 4,484 ✭✭✭Gerry


    g means global to the line, as in every occurence on a line. Otherwise it would only pick up the first one. I have to use this in work every day, and it won't process more than the current line till I give it the line numbers first.

    man vi there paul :)


  • Registered Users, Registered Users 2 Posts: 1,862 ✭✭✭flamegrill


    I was talking purely from a Perl syntax there Phil :)


    Regards,

    Paul

    (VIM OWNS YOREMA)


Advertisement