[英]Using grep to filter rows with two or more patterns in the string in R
[英]Concatenating two patterns using grep
我正在使用這個簡單的 grep 命令來提取相同的字符串模式。
grep -nr -C 3 '\bk[A-Z]\w*' ./*
我的輸出是:
./gpu/command_buffer/service/service_utils.cc:110: command_line->HasSwitch(switches::kCompileShaderAlwaysSucceeds);
./tools/compositor_model_bench/shaders.cc:17:static const int kPositionLocation = 0;
./services/viz/public/cpp/gpu/context_provider_command_buffer.cc:306: switches::kEnableGpuClientTracing)) {
./vulkan/vma_wrapper.cc:46: static_assert(kVulkanRequiredApiVersion >= VK_API_VERSION_1_1, "");
./gpu/command_buffer/service/service_utils.cc:110: command_line->HasSwitch(switches::kSucceeds);
但我需要我的輸出是:
./gpu/command_buffer/service/service_utils.cc:110: command_line->HasSwitch(switches::kCompileShaderAlwaysSucceeds);
./gpu/command_buffer/service/service_utils.cc:110: command_line->HasSwitch(switches::kSucceeds);
我需要提取同時包含 string:- '\\bk[AZ]\\w*'和 string:-開關的行。
grep
和邏輯運算符:
grep A <input_file> | grep B
grep -E "A|B" <input_file>
grep A <input_file> | grep -E "B|C"
所以,在你的情況下:
grep -nr -C 3 '\bk[A-Z]\w*' ./* | grep "switches"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.