|
[Sponsors] |
March 14, 2013, 11:18 |
script for replacing block of code
|
#1 |
Member
Join Date: Nov 2012
Posts: 83
Rep Power: 13 |
Im runnning OpenFoam on a server. im exchanging the data with samba and do the post processing with paraview on windows the problem is that paraview doesn't know the bc:
Code:
inflow { type uniformFixedValue; uniformValue table ( ( 0 (0 0 0.0)) ( 0.0005 (50 0 0.0)) ( 0.0025(600 0 0)) ); } Code:
inflow { type fixedValue; value uniform (600 0 0); } I am looking for a script that is able to replace the whole String block with another one I just manage do replace a string with a script in the subfolder my code for that is (which works but doesn't solve the problem): Code:
#!/bin/bash find . -name "*.txt" -exec sed -i 's/old/new/g' {} \; Can anybody post a script that will replace the bc with the other one? |
|
March 14, 2013, 11:48 |
|
#2 |
Member
|
In vim, you *can* do multiline find-replace. Just use '\n' to capture newlines.
There's probably a better way, as this gets messy. But you can try: Code:
:%s/inflow\n{\ntype uniformFixedValue; \nuniformValue table \n(\n( 0 (0 0 0.0))\n( 0.0005 (50 0 0.0)) \n( 0.0025(600 0 0)) \n);\n}/inflow\r{\rtype fixedValue;\rvalue uniform (600 0 0);\r} Anyways, I just tried this and it worked. |
|
March 15, 2013, 04:32 |
|
#3 |
Member
Join Date: Nov 2012
Posts: 83
Rep Power: 13 |
im really bad at scripting. so i just replaced sed with vim.tiny followed by the long command:
Code:
#!/bin/bash find . -name "*.jsp" -exec vim.tiny :%s/inflow\n{\ntype uniformFixedValue; \nuniformValue table \n(\n( 0 (0 0 0.0))\n( 0.0005 (50 0 0.0)) \n( 0.0025(600 0 0)) \n);\n}/inflow\r{\rtype fixedValue;\rvalue uniform (600 0 0);\r} Can vim be used in a script and is vim.tiny able to do that? vim isn't installed at the server. i sadly haven't worked with vim at all. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] Hexa to Sweep block conversion | pertupd | ANSYS Meshing & Geometry | 1 | June 19, 2010 21:37 |
Running Matlab script from Scheme code | dhimans | Fluent UDF and Scheme Programming | 0 | July 28, 2009 15:13 |
Design Integration with CFD? | John C. Chien | Main CFD Forum | 19 | May 17, 2001 15:56 |
What is the Better Way to Do CFD? | John C. Chien | Main CFD Forum | 54 | April 23, 2001 08:10 |
own Code vs. commercial code | Bernhard Mueck | Main CFD Forum | 10 | February 16, 2000 10:07 |