是否有任何命令可以抑制冗余字符串?

是否有任何命令可以抑制冗余字符串?

使用此命令find $FOAM_TUTORIALS -type f -name fvSchemes|xargs grep -rh div\(phi,U\)|sort,我得到:

    div(div(phi,U)) Gauss linear;
    div(div(phi,U)) Gauss linear;
    div(div(phi,U)) Gauss linear;
    div(phi,U)      bounded Gauss limitedLinear 0.2;
    div(phi,U)      bounded Gauss limitedLinear 0.2;
    div(phi,U)      bounded Gauss limitedLinear 0.2;
    div(phi,U)      bounded  Gauss limitedLinearV 1;
    div(phi,U)      bounded Gauss limitedLinearV 1;
    div(phi,U)      bounded Gauss limitedLinearV 1;
    div(phi,U)          bounded Gauss linear;
    div(phi,U)      bounded Gauss linear;
    div(phi,U)      bounded Gauss linear;
    div(phi,U)      bounded Gauss linear;
    div(phi,U)      bounded Gauss linear;
    div(phi,U)          bounded Gauss linearUpwind grad;
    div(phi,U)       bounded Gauss linearUpwind grad(U);
    div(phi,U)      bounded Gauss linearUpwind grad(U);
    div(phi,U)      bounded Gauss linearUpwind grad(U);
    div(phi,U)      bounded Gauss linearUpwind grad(U);
    div(phi,U)      bounded Gauss linearUpwind grad(U);
    div(phi,U)      bounded Gauss linearUpwind grad(U);
    div(phi,U)         bounded Gauss linearUpwind gradUConv;
    div(phi,U)         bounded Gauss linearUpwind gradUConv;
    div(phi,U)         bounded Gauss linearUpwind gradUConv;
    div(phi,U)         bounded Gauss linearUpwind gradUConv;
    div(phi,U)         bounded Gauss linearUpwind gradUConv;
    div(phi,U)         bounded Gauss linearUpwind gradUConv;
    div(phi,U)         bounded Gauss linearUpwind gradUConv;
    div(phi,U)         bounded Gauss linearUpwind gradUConv;
    div(phi,U)         bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)      bounded Gauss linearUpwind gradUConv;
    div(phi,U)          bounded Gauss linearUpwind limited;
    div(phi,U)      bounded Gauss linearUpwind limited;
    div(phi,U)      bounded Gauss linearUpwind limited;
    div(phi,U)      bounded Gauss linearUpwind limited;
    div(phi,U)      bounded Gauss linearUpwind unlimited;
    div(phi,U)      bounded Gauss linearUpwind unlimited;
    div(phi,U)              bounded Gauss linearUpwindV grad(U);
    div(phi,U)              bounded Gauss linearUpwindV grad(U);
    div(phi,U)      bounded Gauss linearUpwindV grad(U);
    div(phi,U)      bounded Gauss linearUpwindV grad(U);
    div(phi,U)      bounded Gauss linearUpwindV grad(U);
    div(phi,U)      bounded Gauss linearUpwindV grad(U);
    div(phi,U)      bounded Gauss linearUpwindV grad(U);
    div(phi,U)      bounded Gauss linearUpwindV grad(U);
    div(phi,U)      bounded Gauss linearUpwindV grad(U);
    div(phi,U)      bounded Gauss localBlended linearUpwindV grad(U) linear;
    div(phi,U)      bounded Gauss LUST grad(U);
    div(phi,U)                    bounded Gauss upwind;
    div(phi,U)          bounded Gauss upwind;
    div(phi,U)          bounded Gauss upwind;
    div(phi,U)          bounded Gauss upwind;
    div(phi,U)          bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      bounded Gauss upwind;
    div(phi,U)      Gauss CoBlended
    div(phi,U)      Gauss cubic;
    div(phi,U)      Gauss cubic;
    div(phi,U)      Gauss DEShybrid
    div(phi,U)      Gauss DEShybrid
    div(phi,U)      Gauss limitedLinear 1;
    div(phi,U)          Gauss limitedLinearV 1;
    div(phi,U)          Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss limitedLinearV 1;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linear;
//    div(phi,U)      Gauss linear;
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)      Gauss linearUpwind grad(U);
    div(phi,U)          Gauss linearUpwind limited;
    div(phi,U)          Gauss linearUpwind limited;
    div(phi,U)      Gauss linearUpwind limited;
    div(phi,U)      Gauss linearUpwindV grad(U);
    div(phi,U)      Gauss LUST grad(U);
    div(phi,U)      Gauss LUST grad(U);
    div(phi,U)      Gauss LUST grad(U);
    div(phi,U)      Gauss LUST grad(U);
    div(phi,U)      Gauss LUST grad(U);
    div(phi,U)      Gauss LUST grad(U);
    div(phi,U)      Gauss LUST grad(U);
    div(phi,U)      Gauss LUST grad(U);
    div(phi,U)      Gauss LUST grad(U);
    div(phi,U)      Gauss LUST grad(U);
//    div(phi,U)      Gauss LUST grad(U);// linear;
    div(phi,U)      Gauss LUST unlimitedGrad(U);
    div(phi,U)      Gauss skewCorrected linear;
    div(phi,U)          Gauss upwind;
    div(phi,U)          Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;
//    div(phi,U)      Gauss upwind;
//    div(phi,U)      Gauss upwind;
//    div(phi,U)      Gauss upwind;
//    div(phi,U)      Gauss upwind;
//    div(phi,U)      Gauss upwind;
    div(phi,U)      Gauss upwind;//linearUpwind grad(U);
    div(phi,U)      Gauss vanLeerV;

我希望冗余的行仅显示一次,如下所示:

div(phi,U)      bounded Gauss limitedLinear 0.2;
div(phi,U)      bounded Gauss limitedLinearV 1;
div(phi,U)      bounded Gauss linear;
div(phi,U)      bounded Gauss linearUpwind grad;
div(phi,U)      bounded Gauss linearUpwind grad(U);
div(phi,U)      bounded Gauss linearUpwind gradUConv;
div(phi,U)      bounded Gauss linearUpwind limited;
div(phi,U)      bounded Gauss linearUpwind unlimited;
div(phi,U)      bounded Gauss linearUpwindV grad(U);
div(phi,U)      bounded Gauss localBlended linearUpwindV grad(U) linear;
div(phi,U)      bounded Gauss LUST grad(U);
div(phi,U)      bounded Gauss upwind;
div(phi,U)      Gauss CoBlended 0.01 limitedLinearV 1 0.05 linearUpwind grad(U);
div(phi,U)      Gauss cubic;
div(phi,U)      Gauss DEShybrid linear linearUpwind grad(U) hmax 0.65 1 0.028 0 1 1;
div(phi,U)      Gauss DEShybrid linear linearUpwind grad(U) hmax 0.65 1 1 0 1 1;
div(phi,U)      Gauss limitedLinear 1;
"div\(phi.*,U.*\)" Gauss limitedLinearV 1;
div(phi,U)      Gauss limitedLinearV 1;
div(phi,U)      Gauss linear;
div(phi,U)      Gauss linearUpwind grad(U);
div(phi,U)      Gauss linearUpwind limited;
div(phi,U)      Gauss linearUpwindV grad(U);
div(phi,U)      Gauss LUST grad(U);
div(phi,U)      Gauss LUST unlimitedGrad(U);
div(phi,U)      Gauss skewCorrected linear;
"div\(phi.*,U.*\)" Gauss upwind;
div(phi,U)      Gauss upwind;
div(phi,U)      Gauss vanLeerV;

答案1

假设您的输入位于名为 的文件中inputfile.txt

您可以运行: sed -e 's/ \+/ /g' inputfile.txt | grep -v "\/\/" | sort -u

解释:

  • sed -e 's/ \+/ /g' inputfile.txt将多个空白替换为一个空白。这样,执行最终排序/比较会更简单
  • grep -v "\/\/"删除注释行
  • 最终sort -u删除重复的行。

如果您不介意用一个空格替换多个空格,那么此解决方案效果很好。

这些命令可以通过这种方式合并到您的原始命令中:

find $FOAM_TUTORIALS -type f -name fvSchemes | xargs grep -rh div\(phi,U\) | sed -e 's/ \+/ /g' | grep -v "\/\/" | sort -u

相关内容