Because there is no *.sql file.
grep на Windows 7 Неверный аргумент
Я использую grep из Gnuwin32 на Windows.
Выполнение:
grep -r INSERT *.sql
Урожайность:
grep: *.sql: Invalid argument
Есть идеи почему?
3 ответа на вопрос
According to the Grep manual:
-r
with grep is recursive directory searching, so to use it you specify the starting directory, not a file mask.
e.g.:
grep -r INSERT .
would look at all files for INSERT, starting at the current directory (.
) and recursively working its way through the sub-folders.
To specify recursive folder checking and specify a file wildcard to limit searches, you can use the --include
option:
grep -r --include "*.sql" INSERT .
Similar question/info over on StackOverflow: How do I grep recursively?
grep
is a great tool with some interesting parameters. However, as its name says (globally search a regular expression and print) it is meant for matching things. If what you want is to find files, use find
.
In this case, it looks like you want to look for the text INSERT
within files that are in this tree.
For this, you need to do something like:
find -name "*.sql" grep -h INSERT {} \;
find -name "*.sql"
will find all these files and then grep -h
will print those having the text INSERT
in them.
Why wasn't your approach working?
Because by saying grep -r ... *.sql
, bash tries to expand that *.sql
before performing the command. But nothing matches *.sql
in your directory, so it cannot work.
You can use the --include
parameter with a regexp, but -in my experience- it is quite fragile.
Похожие вопросы
-
2
Windows 7 Home Premium запоминает пароли общего доступа к сети?
-
4
Как заблокировать выровненные по правому краю панели инструментов в Windows 7, чтобы они не выглядел...
-
4
Функция Windows 7 «Aero Snap» в Ubuntu GNOME
-
-
3
Мой второй жесткий диск не виден в Windows 7
-
7
Как заменить Блокнот в Windows 7?
-
2
Как расположить значки панели задач Windows 7 в 2 ряда?
-
1
Проблемы во время сна на Windows 7
-
6
Как управлять функцией привязки Windows 7 с помощью двух мониторов?
-
10
Как мне обновить Windows 7 RC до Windows 7 RTM?
-
3
Какая защита от шпионского ПО доступна для Windows 7?