我有一个文件,我想从中提取两个值(时间,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