我有一個文件,我想從中提取兩個值(時間,C_F [6]),下面突出顯示。它在CentOS 7環境中可以使用bash或gnuplot或r。我甚至不知道如何谷歌(例如,從文件bash提取值並不真正拿出解決方案)。它是否可行?從文件中提取值和平均值
我希望能夠:
- 劇情時間與C_F [6]
- 平均C_F [6]
編輯1:
我認爲這可能是上線,但它重現整個文件 個SED的/^.* C_F [6] = //'C_F.pressure> OUTPUTFILE
編輯2:
Extract of the file:
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ /F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 3.0.0 |
| \\/ A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 3.0.0-6abec57f5449
Exec : patchAverage p C_F -parallel
Date : Apr 15 2017
Time : 15:01:20
Host : "login2.jjj.uk"
PID : 59764
Case : /nobackup/jjjj/Silsoe/Solid/solid_0_LES/motorBikeLES
nProcs : 8
Slaves :
7
(
"login2.jjjj.59765"
"login2.jjjj.59766"
"login2.jjjj.59767"
"login2.jjjj.59768"
"login2.jjjj.59769"
"login2.jjjj.59770"
"login2.jjjj.59771"
)
Pstream initialized with:
floatTransfer : 0
nProcsSimpleSum : 0
commsType : nonBlocking
polling iterations : 0
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time
Create mesh for time = 0.18
Time = 0.18
Reading volScalarField p
Average of volScalarField over patch C_F[6] = -18.3176
Time = 0.19
Reading volScalarField p
Average of volScalarField over patch C_F[6] = -18.299
Time = 0.2
Reading volScalarField p
Average of volScalarField over patch C_F[6] = -18.2704
Time = 0.21
Reading volScalarField p
Average of volScalarField over patch C_F[6] = -18.2349
你能鏈接一個示例文件嗎?我在這些情況下所做的是提取文件中的行(使用'readLine'等函數),然後查找包含特定模式(如Time ='和C_F [6])的行(使用'grep'或類似函數) '。也許可以清理這些行,以便數字部分將被保留。您可以複製粘貼文本從「// ****************」到任何一個例子。 – din