Results 1 to 3 of 3

Thread: Script for replacing a line in another script

  1. #1
    Join Date
    Feb 2009
    Location
    Seward, AK
    Beans
    88
    Distro
    Kubuntu 13.10 Saucy Salamander

    Script for replacing a line in another script

    I'm looking to see if its possible to create a script that takes the path in the currently focused nautilus window and outputs it as a line in another script.

    I have a script that opens the folder to the current audiobook I'm listening to open on boot, but since sometimes the book I'm listening to changes frquently, I'd like to just run a script to edit my startup script instead of editing it by hand.

    Is this possible?
    You can have quality, price, or performance, but you can only choose two.

  2. #2
    Join Date
    Jun 2009
    Location
    Land of Paranoia and Guns
    Beans
    194
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Script for replacing a line in another script

    You can do this with a nautilus script and sed. Nautilus scripts have a number of context sensitive variables made available to them, such as $NAUTILUS_SCRIPT_CURRENT_URI for the current directory. So to change the variable var in the script ~/script.sh to the current directory, you would place this script in ~/.gnome2/nautilus-scripts:
    Code:
    #!/bin/sh
    # The -i.bak creates a backup of the edited file with the extension .bak
    sed -i.bak 's:var=.*$:var='$NAUTILUS_SCRIPT_CURRENT_URI':' ~/script.sh
    Don't use W3Schools as a resource! (Inconsequential foul language at the jump)
    Open Linux Forums (More foul language, but well worth it for the quality of support and good humor.)
    If you want to discuss W3Schools, please PM me instead of posting.

  3. #3
    Join Date
    Feb 2009
    Location
    Seward, AK
    Beans
    88
    Distro
    Kubuntu 13.10 Saucy Salamander

    Re: Script for replacing a line in another script

    Ahh, ok. When I first read this a few days ago, it looked like gibbersih due to lack of sleep. Now I know what you mean, heh.

    I just did a fresh install of 12.04 and its gonna take me a few days to get back around to setting my startup scripts again.
    You can have quality, price, or performance, but you can only choose two.

Bookmarks

Posting Permissions

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