![]() |
|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
![]() |
|
Thread Tools | Display Modes |
|
||||
![]()
If I'm understanding your quandary: you can replace values in files "in place" with sed. See the manpages for sed(1) -- the -i option (which can be used with or without making a backup).
--- edit ---- I replied with that info after looking at a FBSD 6.3 box. The 7.0 manpages are slightly different, so you may really need the -I option if you're running 7.
__________________
Kill your t.v. Last edited by anomie; 22nd September 2008 at 08:46 PM. |
|
||||
![]()
I knew there must be one
![]() Actually, I tested both 6.3 and 7.0. "-i" or "-I" switch isnt enough, sed needs "-e" (edit) as well to make it work ![]() Is there any catch? I see ppl tend to dump the output to a temp file, rather than edit the file on the fly :S
__________________
The power of plain text? It can control an entire OS |
|
||||
![]()
A more portable approach then relying on GNU SED / FreeBSD SED; might be to use perl, if you know the language.
Code:
$ perl -i -pe 's/foo/bar/g' file NB that because -i renames or deletes the original file before creating a new file of the same name, UNIX-style soft and hard links will not be preserved. see perlre, perlrequick, perlreref, perlretut manual pages; if necessary for more advanced pattern matching notes.
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
![]() |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find command (Linux options?) | deadeyes | FreeBSD General | 11 | 23rd August 2009 06:07 PM |
Creating 2 slices | Beastie | FreeBSD Installation and Upgrading | 7 | 23rd March 2009 12:22 AM |
Running a command with input from a file. | bigb89 | Programming | 4 | 21st January 2009 06:36 PM |
how to enable file/command completion for ksh93? | TerryP | General software and network | 1 | 31st August 2008 08:23 AM |
Find pattern in a file and erase it | c0mrade | Programming | 8 | 25th June 2008 05:31 PM |