{ "version": "https://jsonfeed.org/version/1.1", "user_comment": "This feed allows you to read the posts from this site in any feed reader that supports the JSON Feed format. To add this feed to your reader, copy the following URL -- https://matoken.org/blog/tag/grep/feed/json -- and add it your reader.", "home_page_url": "https://matoken.org/blog/tag/grep", "feed_url": "https://matoken.org/blog/tag/grep/feed/json", "language": "ja", "title": "grep – matoken's blog", "description": "Is there no plan B?", "icon": "https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9.jpeg", "items": [ { "id": "https://matoken.org/blog/?p=4629", "url": "https://matoken.org/blog/2025/06/23/show-all-after-match-line-with-ugrep/", "title": "ugrep\u3067\u30de\u30c3\u30c1\u884c\u4ee5\u964d\u5168\u3066\u8868\u793a", "content_html": "
\n
\n

\n
\n

grep\u30b3\u30de\u30f3\u30c9\u306b\u30de\u30c3\u30c1\u3057\u305f\u90e8\u5206\u304b\u3089\u6307\u5b9a\u884c\u3092\u8868\u793a\u3059\u308b\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\uff0e
\n\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f\u30de\u30c3\u30c1\u3057\u305f\u90e8\u5206\u304b\u3089\u5f8c\u308d11\u884c\u3092\u8868\u793a\uff0e

\n
\n
\n
\n
$ man grep | grep 'Context Line Control' -A 11\n   Context Line Control\n       -A NUM, --after-context=NUM\n              Print NUM lines of trailing context after matching lines.  Places a line containing a group separator (--) between contiguous groups of matches.  With the -o or --only-matching option, this has no effect  and  a  warning  is\n              given.\n\n       -B NUM, --before-context=NUM\n              Print  NUM  lines  of  leading context before matching lines.  Places a line containing a group separator (--) between contiguous groups of matches.  With the -o or --only-matching option, this has no effect and a warning is\n              given.\n\n       -C NUM, -NUM, --context=NUM\n              Print NUM lines of output context.  Places a line containing a group separator (--) between contiguous groups of matches.  With the -o or --only-matching option, this has no effect and a warning is given.
\n
\n
\n
\n

\u30de\u30c3\u30c1\u3057\u305f\u90e8\u5206\u4ee5\u964d\u5168\u3066\u3092\u8868\u793a\u3057\u305f\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\uff0e\u884c\u6570\u3092\u78ba\u8a8d\u3059\u308b\u306e\u304c\u9762\u5012\u3060\u3063\u305f\u308a\u3059\u308b\u306e\u3067 -A 999 \u3068\u304b\u3084\u308a\u304c\u3061\u3067\u3059\uff0e

\n
\n
\n

ugrep \u306b\u6700\u5f8c\u307e\u3067\u8868\u793a\u3067\u304d\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3042\u308b\u306e\u306b\u6c17\u3065\u3044\u305f\u306e\u3067\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\uff0e

\n
\n

\n\n
\n

Debian\u3067\u306fGNU grep\u306f grep \u30d1\u30c3\u30b1\u30fc\u30b8\u3067\uff0cugrep \u306f ugrep \u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\uff0e

\n
\n
\n
\u5c0e\u5165
\n
\n
$ sudo apt install grep\n$ sudo apt install ugrep
\n
\n
\n
\n
\n
\n

GNU grep \u3092\u8a66\u3059

\n
\n
\n
\u9069\u5f53\u306a\u30c6\u30ad\u30b9\u30c8
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head\nroot\ndaemon\nbin\nsys\nsync\ngames\nman\nlp\nmail\nnews
\n
\n
\n
\n
GNU grep \u3067 man \u306e\u5f8c2\u884c\u3092\u8868\u793a
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -A2 -- ^man$\nman\nlp\nmail
\n
\n
\n
\n
GNU grep \u3067 man \u306e\u524d2\u884c\u3092\u8868\u793a
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -B2 -- ^man$\nsync\ngames\nman
\n
\n
\n
\n
GNU grep \u3067 man \u306e\u524d\u5f8c\u305d\u308c\u305e\u308c2\u884c\u3092\u8868\u793a
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -C2 -- ^man$\nsync\ngames\nman\nlp\nmail
\n
\n
\n
\n
GNU grep \u3067 man \u306e\u524d1\u884c\u5f8c2\u884c\u3092\u8868\u793a
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -B1 -A2 -- ^man$\ngames\nman\nlp\nmail
\n
\n
\n
\n
GNU grep \u3067 man \u306e\u5f8c99\u884c\u3092\u8868\u793a(\u5b9f\u969b\u306f\u305d\u3093\u306a\u306b\u884c\u6570\u304c\u306a\u3044\u306e\u3067\u6700\u5f8c\u307e\u3067\u8868\u793a)
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -A99 -- ^man$\nman\nlp\nmail\nnews
\n
\n
\n
\n
\n
\n

ugrep \u3092\u8a66\u3059

\n
\n
\n

ugrep \u3082GNU grep\u3068\u540c\u3058\u3088\u3046\u306b -A/-B/-C \u304c\u4f7f\u3048\u307e\u3059\uff0e\u305d\u3057\u3066 -A \u5229\u7528\u6642\u306b\u306f\u884c\u6570\u306b -1 \u304c\u6307\u5b9a\u53ef\u80fd\u3067\u3053\u308c\u3067\u30de\u30c3\u30c1\u90e8\u5206\u304b\u3089\u6700\u5f8c\u307e\u3067\u8868\u793a\u3067\u304d\u307e\u3059\uff0e

\n
\n
\n
grep \u3067 man \u306e\u5f8c\u3059\u3079\u3066\u3092\u8868\u793a
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | ugrep -A-1 -- ^man$\nman\nlp\nmail\nnews
\n
\n
\n
\n
-B \u306b\u306f\u4f7f\u3048\u306a\u3044
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | ugrep -B-1 -- ^man$\nugrep: warning: exception while searching (standard input): Inappropriate ioctl for device
\n
\n
\n
\n
tac\u3067\u9006\u9806\u306b\u3057\u3066 -1 \u3067\u5207\u308a\u53d6\u3063\u305f\u3068\u518d\u5ea6tac\u3067\u9006\u9806\u306b
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | tac | ugrep -A-1 -- ^man$ | tac\nroot\ndaemon\nbin\nsys\nsync\ngames\nman
\n
\n
\n
\n

ugrep\u306f\u4ed6\u306b\u3082\u5bfe\u8a71\u578b\u554f\u3044\u5408\u308f\u305b\u306e\u6a5f\u80fd(-Q)\u3084\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u3066\u691c\u7d22\u3092\u9ad8\u901f\u5316(-indexer)\u3059\u308b\u6a5f\u80fd\u306a\u3069\u69d8\u3005\u306a\u6a5f\u80fd\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\uff0e
\n\u3082\u3063\u3068\u4f7f\u3044\u3053\u306a\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u3053\u308d\u3067\u3059\uff0e

\n
\n
\n
\n
\n

\u5225\u89e3: sed, awk, perl

\n
\n
\n
sed
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | sed -n '/^man$/,$p'\nman\nlp\nmail\nnews
\n
\n
\n
\n
awk
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | awk '/^man$/',0\nman\nlp\nmail\nnews
\n
\n
\n
\n
perl
\n
\n
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | perl -ne \"print if /^man$/ .. eof;\"\nman\nlp\nmail\nnews
\n
\n
\n
\n
\n
\n

\u74b0\u5883

\n
\n
\n
\n
$ dpkg-query -W grep ugrep sed gawk perl\ngawk    1:5.3.2-1\ngrep    3.11-4\nperl    5.40.1-3\nsed     4.9-2\nugrep   7.4.2+dfsg-1\n$ lsb_release -dr\nDescription:    Debian GNU/Linux 13 (trixie)\nRelease:        13\n$ arch\nx86_64
\n
\n
\n
\n
\n", "content_text": "grep\u30b3\u30de\u30f3\u30c9\u306b\u30de\u30c3\u30c1\u3057\u305f\u90e8\u5206\u304b\u3089\u6307\u5b9a\u884c\u3092\u8868\u793a\u3059\u308b\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\uff0e\n\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f\u30de\u30c3\u30c1\u3057\u305f\u90e8\u5206\u304b\u3089\u5f8c\u308d11\u884c\u3092\u8868\u793a\uff0e\n\n\n\n$ man grep | grep 'Context Line Control' -A 11\n Context Line Control\n -A NUM, --after-context=NUM\n Print NUM lines of trailing context after matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is\n given.\n\n -B NUM, --before-context=NUM\n Print NUM lines of leading context before matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is\n given.\n\n -C NUM, -NUM, --context=NUM\n Print NUM lines of output context. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given.\n\n\n\n\u30de\u30c3\u30c1\u3057\u305f\u90e8\u5206\u4ee5\u964d\u5168\u3066\u3092\u8868\u793a\u3057\u305f\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\uff0e\u884c\u6570\u3092\u78ba\u8a8d\u3059\u308b\u306e\u304c\u9762\u5012\u3060\u3063\u305f\u308a\u3059\u308b\u306e\u3067 -A 999 \u3068\u304b\u3084\u308a\u304c\u3061\u3067\u3059\uff0e\n\n\nugrep \u306b\u6700\u5f8c\u307e\u3067\u8868\u793a\u3067\u304d\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3042\u308b\u306e\u306b\u6c17\u3065\u3044\u305f\u306e\u3067\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\uff0e\n\n\n\n\n\nGrep – GNU Project – Free Software Foundation\n\n\nHome \u00b7 Genivia/ugrep Wiki\n\n\n\nThe ugrep file pattern searcher\n\n\n\n\n\n\n\nDebian\u3067\u306fGNU grep\u306f grep \u30d1\u30c3\u30b1\u30fc\u30b8\u3067\uff0cugrep \u306f ugrep \u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\uff0e\n\n\n\u5c0e\u5165\n\n$ sudo apt install grep\n$ sudo apt install ugrep\n\n\n\n\n\nGNU grep \u3092\u8a66\u3059\n\n\n\u9069\u5f53\u306a\u30c6\u30ad\u30b9\u30c8\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head\nroot\ndaemon\nbin\nsys\nsync\ngames\nman\nlp\nmail\nnews\n\n\n\nGNU grep \u3067 man \u306e\u5f8c2\u884c\u3092\u8868\u793a\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -A2 -- ^man$\nman\nlp\nmail\n\n\n\nGNU grep \u3067 man \u306e\u524d2\u884c\u3092\u8868\u793a\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -B2 -- ^man$\nsync\ngames\nman\n\n\n\nGNU grep \u3067 man \u306e\u524d\u5f8c\u305d\u308c\u305e\u308c2\u884c\u3092\u8868\u793a\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -C2 -- ^man$\nsync\ngames\nman\nlp\nmail\n\n\n\nGNU grep \u3067 man \u306e\u524d1\u884c\u5f8c2\u884c\u3092\u8868\u793a\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -B1 -A2 -- ^man$\ngames\nman\nlp\nmail\n\n\n\nGNU grep \u3067 man \u306e\u5f8c99\u884c\u3092\u8868\u793a(\u5b9f\u969b\u306f\u305d\u3093\u306a\u306b\u884c\u6570\u304c\u306a\u3044\u306e\u3067\u6700\u5f8c\u307e\u3067\u8868\u793a)\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -A99 -- ^man$\nman\nlp\nmail\nnews\n\n\n\n\n\nugrep \u3092\u8a66\u3059\n\n\nugrep \u3082GNU grep\u3068\u540c\u3058\u3088\u3046\u306b -A/-B/-C \u304c\u4f7f\u3048\u307e\u3059\uff0e\u305d\u3057\u3066 -A \u5229\u7528\u6642\u306b\u306f\u884c\u6570\u306b -1 \u304c\u6307\u5b9a\u53ef\u80fd\u3067\u3053\u308c\u3067\u30de\u30c3\u30c1\u90e8\u5206\u304b\u3089\u6700\u5f8c\u307e\u3067\u8868\u793a\u3067\u304d\u307e\u3059\uff0e\n\n\ngrep \u3067 man \u306e\u5f8c\u3059\u3079\u3066\u3092\u8868\u793a\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | ugrep -A-1 -- ^man$\nman\nlp\nmail\nnews\n\n\n\n-B \u306b\u306f\u4f7f\u3048\u306a\u3044\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | ugrep -B-1 -- ^man$\nugrep: warning: exception while searching (standard input): Inappropriate ioctl for device\n\n\n\ntac\u3067\u9006\u9806\u306b\u3057\u3066 -1 \u3067\u5207\u308a\u53d6\u3063\u305f\u3068\u518d\u5ea6tac\u3067\u9006\u9806\u306b\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | tac | ugrep -A-1 -- ^man$ | tac\nroot\ndaemon\nbin\nsys\nsync\ngames\nman\n\n\n\nugrep\u306f\u4ed6\u306b\u3082\u5bfe\u8a71\u578b\u554f\u3044\u5408\u308f\u305b\u306e\u6a5f\u80fd(-Q)\u3084\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u6210\u3057\u3066\u691c\u7d22\u3092\u9ad8\u901f\u5316(-indexer)\u3059\u308b\u6a5f\u80fd\u306a\u3069\u69d8\u3005\u306a\u6a5f\u80fd\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\uff0e\n\u3082\u3063\u3068\u4f7f\u3044\u3053\u306a\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u3053\u308d\u3067\u3059\uff0e\n\n\n\n\n\u5225\u89e3: sed, awk, perl\n\n\nsed\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | sed -n '/^man$/,$p'\nman\nlp\nmail\nnews\n\n\n\nawk\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | awk '/^man$/',0\nman\nlp\nmail\nnews\n\n\n\nperl\n\n$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | perl -ne \"print if /^man$/ .. eof;\"\nman\nlp\nmail\nnews\n\n\n\n\n\n\u74b0\u5883\n\n\n\n$ dpkg-query -W grep ugrep sed gawk perl\ngawk 1:5.3.2-1\ngrep 3.11-4\nperl 5.40.1-3\nsed 4.9-2\nugrep 7.4.2+dfsg-1\n$ lsb_release -dr\nDescription: Debian GNU/Linux 13 (trixie)\nRelease: 13\n$ arch\nx86_64", "date_published": "2025-06-23T06:38:00+09:00", "date_modified": "2025-06-23T00:42:05+09:00", "authors": [ { "name": "matoken", "url": "https://matoken.org/blog/author/matoken/", "avatar": "https://secure.gravatar.com/avatar/38f5f3b575c5eb45cda6aa659bca119ac7a5e16b46565e869d0030e3bd66981d?s=512&d=mm&r=g" } ], "author": { "name": "matoken", "url": "https://matoken.org/blog/author/matoken/", "avatar": "https://secure.gravatar.com/avatar/38f5f3b575c5eb45cda6aa659bca119ac7a5e16b46565e869d0030e3bd66981d?s=512&d=mm&r=g" }, "tags": [ "grep", "ugrep", "Debian", "Linux", "sid" ] } ] }