你如何配置grep以更像ack?(How do you configure grep to act more like ack?)
如何在不键入排除模式的情况下获取grep以排除ack排除的文件(临时文件和版本控制目录)?
如此处所述 ,您可以使用GREP_OPTIONS,但是这里遇到了问题 :使用grep而不清除GREP_OPTIONS的脚本将会中断。
有什么更好的方法? 别名? 还是包含grep的另一个脚本?
虽然明显的答案是
alias grep="ack -a"
,但我在学术上对如何在不使用ack的情况下解决这个问题感兴趣。How would you get grep to exclude the files that ack excludes (temp files and version control directories) without typing out the exclude patterns?
As described here, you could use GREP_OPTIONS, but then you run into the problems here: scripts that use grep without clearing GREP_OPTIONS will break.
What is the better way? An alias? Or another script that wraps grep?
While the obvious answer is
alias grep="ack -a"
, I'm academically interested in how to solve this problem without using ack.
原文:https://stackoverflow.com/questions/11713507
最满意答案
你的代码不起作用的原因在于你的
no
数组的内容:它包含一个单字母字符串"n"
。 是这个字符串no.Any( input.Contains )
对于包含字母
'n'
任何输入字符串,求值为True
。为了解决这个问题,您可以将
walk
的检查移动到if
/then
/else
链的顶部。 但是,解决方案不会过于强大:"yellow"
将被归类为"yes"
,"cat"
将变为"clear"
,依此类推。The reason your code does not work is in the content of your
no
array: it contains a single-letter string"n"
. It is this string that makesno.Any( input.Contains )
evaluate to
True
for any input string that contains letter'n'
.In order to fix this problem, you can move the checks for
walk
to the top of theif
/then
/else
chain. However, the solution would not be overly robust:"yellow"
would be classified as"yes"
,"cat"
would become"clear"
, and so on.
相关问答
更多-
LINUX 如何查看JPG文件[2022-06-13]
find -
看起来您没有使用mysql_select_db选择数据库。 尝试将您的die语句更改为: die("Error: Could not show columns - ". mysql_error());` 在将代码移至生产环境之前,请务必将其删除。 Looks like you haven't selected a database using mysql_select_db. Try changing your die statement to: die("Error: Could not show co ...
-
在数组中查找常用值(Find common values in array)[2022-06-19]
简单如π $arrays = array(2,3); $result_array = array( 0 => array(0 => "1", 1 => "sa", 2 => "asa", 3 => "sas", 4 => "asa", 5 => "ada", 6 => "Y" ), 1 => arra ... -
a = [0, 0, 10, 0, 3, 1] a.each_index.max_by(3){|i| a[i]} # => [2, 4, 5] 要么 [0, 0, 10, 0, 3, 1].each_with_index.max(3).map(&:last) # => [2, 4, 5] a = [0, 0, 10, 0, 3, 1] a.each_index.max_by(3){|i| a[i]} # => [2, 4, 5] or [0, 0, 10, 0, 3, 1].each_with_ind ...
-
尝试这个代码这对我有用。
在数组值中查找单词(Find words in array values)[2022-04-11]
你需要遍历数组: foreach($image_names as $image_name){ if (strpos($image_name,'own') !== false) OR (strpos($image_name,'my') !== false)) { $error = 'Dont use words like my, own etc.'; } } You need to loop through the array: foreach($image_nam ...在数组值之间查找值(Find value between array values)[2023-11-19]
我认为一个简单的foreach足够快,在浮点比较中有一些预防措施:在这里看到它: http : //codepad.org/sZkDJJQb 0, 'max' => 4.999, 'val' => 'low'), array( 'min' => 5, 'max' => 9.999, 'val' => 'med'), array( 'min' => 10, 'max' => 14.999, ...这个问题的诀窍是首先对数组进行排序。 这样就可以让你只需要比较彼此相邻的数字; 选择具有最小差异的2。 伪代码: sort the array: use Arrays.sort() int max_difference = Integer.MAXVALUE int val1, val2; for(i=0; i< array_size -1; ++i) { int x = array[i+1] - array[i]; if(x <= max_difference) { max_difference ...尝试通过在嵌套的min循环中输入以下行来调试代码: System.out.println("the value of numbers[i] is: " + numbers[i]); 所以它看起来像这样: for (int j=0; j < 5; j++) //finds five lowest...array not assigned values { for (int i=0; i < numbers.length; i++) { if (numbers[i ...在数组中找不到一些值(Can't find some values in array)[2023-06-15]
你的代码不起作用的原因在于你的no数组的内容:它包含一个单字母字符串"n" 。 是这个字符串 no.Any( input.Contains ) 对于包含字母'n'任何输入字符串,求值为True 。 为了解决这个问题,您可以将walk的检查移动到if / then / else链的顶部。 但是,解决方案不会过于强大: "yellow"将被归类为"yes" , "cat"将变为"clear" ,依此类推。 The reason your code does not work is in the content ...相关文章
更多- configure原理
- Storm ack和fail机制再论
- grep 零宽断言
- 使用grep和正则来分析Web服务器日志
- linux下杀tomcat脚本
- Hadoop单机模式测试
- 一篇老外写的精典会话劫持的文章
- Storm常见问题(笔记)
- Storm-源码分析- bolt (backtype.storm.task)
- storm单机版安装配置
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)