Вам нужно будет убедиться, что у вас есть Options -MultiViews
.
Ни одно из вышеперечисленных не работало для меня на стандартном хосте cPanel.
Это сработало:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Попробуйте grep -o
grep -oh "\w*th\w*" *
Изменить: соответствие из комментария Фила
Из документы :
-h, --no-filename
Suppress the prefixing of file names on output. This is the default
when there is only one file (or only standard input) to search.
-o, --only-matching
Print only the matched (non-empty) parts of a matching line,
with each such part on a separate output line.
Просто awk
, не требуется комбинация инструментов.
# awk '{for(i=1;i<=NF;i++){if($i~/^th/){print $i}}}' file
the
the
the
this
thoroughly
Вы можете передать вывод grep в Perl следующим образом:
grep "th" * | perl -n -e'while(/(\w*th\w*)/g) {print "$1\n"}'
Вы можете преобразовать пробелы в символы новой строки, а затем grep, например:
cat * | tr ' ' '\n' | grep th
Вы также можете попробовать pcregrep . В grep также есть опция -w
, но в некоторых случаях она работает не так, как ожидалось.
Из Википедия :
cat fruitlist.txt
apple
apples
pineapple
apple-
apple-fruit
fruit-apple
grep -w apple fruitlist.txt
apple
apple-
apple-fruit
fruit-apple