{"id":712,"date":"2023-09-29T18:46:28","date_gmt":"2022-12-27T06:34:20","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/index.php\/2023\/11\/30\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/"},"modified":"2025-08-01T01:51:48","modified_gmt":"2025-07-31T16:51:48","slug":"linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/","title":{"rendered":"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9"},"content":{"rendered":"<p>Linux\u3084Unix\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u3001Grep\u3068\u3044\u3046\u30b3\u30de\u30f3\u30c9\u304c\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002Grep\u306f\u300c\u30b0\u30ed\u30fc\u30d0\u30eb\u6b63\u898f\u8868\u73fe\u30d7\u30ea\u30f3\u30c8\u300d\u3068\u3044\u3046\u610f\u5473\u3067\u3001\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u691c\u7d22\u304a\u3088\u3073\u30de\u30c3\u30c1\u30f3\u30b0\u3059\u308b\u305f\u3081\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3059\u3002\u3055\u3089\u306b\u3001\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3059\u3079\u3066\u306eLinux\u30c7\u30a3\u30b9\u30c8\u30ea\u30d3\u30e5\u30fc\u30b7\u30e7\u30f3\u306b\u4e8b\u524d\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u30ac\u30a4\u30c9\u3067\u306f\u3001\u4e00\u822c\u7684\u306agrep\u30b3\u30de\u30f3\u30c9\u306e\u4f7f\u7528\u65b9\u6cd5\u3068\u3044\u304f\u3064\u304b\u306e\u4f8b\u3092\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>Linux\u3067\u306eGrep\u30b3\u30de\u30f3\u30c9<\/h2>\n<p>Grep\u30b3\u30de\u30f3\u30c9\u306f\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u5185\u306e\u6b63\u898f\u8868\u73fe\u307e\u305f\u306f\u6587\u5b57\u5217\u3092\u691c\u7d22\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u3092\u5b9f\u8a3c\u3059\u308b\u305f\u3081\u306b\u3001welcome.txt\u3068\u3044\u3046\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u8ffd\u52a0\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"post-pre\"><code>Welcome to Linux !\r\nLinux is a free and opensource Operating system that is mostly used by\r\ndevelopers and in production servers for hosting crucial components such as web\r\nand database servers. Linux has also made a name for itself in PCs.\r\nBeginners looking to experiment with Linux can get started with friendlier linux\r\ndistributions such as Ubuntu, Mint, Fedora and Elementary OS.\r\n<\/code><\/pre>\n<p>\u7d20\u6674\u3089\u3057\u3044\uff01\u4eca\u3067\u306f\u3001\u3044\u304f\u3064\u304b\u306egrep\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3001\u51fa\u529b\u3092\u64cd\u4f5c\u3057\u3066\u671b\u3080\u7d50\u679c\u3092\u5f97\u308b\u6e96\u5099\u304c\u6574\u3044\u307e\u3057\u305f\u3002\u30d5\u30a1\u30a4\u30eb\u5185\u306e\u6587\u5b57\u5217\u3092\u691c\u7d22\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u69cb\u6587\u3067\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code>$ grep \"string\" file name\r\n<\/code><\/pre>\n<p>\u307e\u305f\u306f<\/p>\n<pre class=\"post-pre\"><code>$ filename grep \"string\"\r\n<\/code><\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u65e5\u672c\u8a9e\u3067\u8a00\u3063\u3066\u304f\u3060\u3055\u3044\uff1a<\/p>\n<p>\u4f8b\u6587:<\/p>\n<pre class=\"post-pre\"><code>$ grep \"Linux\" welcome.txt\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/10-0.png\" alt=\"grep command usage\" \/><\/div>\n<pre class=\"post-pre\"><code>$ grep \"string\" \/path\/to\/file\r\n<\/code><\/pre>\n<h2>&#8211;color\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066Grep\u306e\u7d50\u679c\u306b\u8272\u3092\u4ed8\u3051\u308b\u3002<\/h2>\n<p>\u3082\u3057\u691c\u7d22\u6587\u5b57\u5217\u3084\u30d1\u30bf\u30fc\u30f3\u304c\u4ed6\u306e\u30c6\u30ad\u30b9\u30c8\u3068\u7570\u306a\u308b\u8272\u3067\u8868\u793a\u3055\u308c\u306a\u3044\u30b7\u30b9\u30c6\u30e0\u3067\u4f5c\u696d\u3057\u3066\u3044\u308b\u5834\u5408\u3001&#8211;color\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u7d50\u679c\u3092\u76ee\u7acb\u305f\u305b\u308b\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4f8b\u3048\u3070\u3001<\/p>\n<pre class=\"post-pre\"><code>$ grep --color \"free and opensource\" welcome.txt \r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/15-0.png\" alt=\"grep command usage\" \/><\/div>\n<h2>\u3059\u3079\u3066\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u518d\u5e30\u7684\u306b\u6587\u5b57\u5217\u3092\u691c\u7d22\u3059\u308b\u3002<\/h2>\n<p>\u300c-r\u300d\u30d5\u30e9\u30b0\u3092\u4f7f\u7528\u3057\u3066\u3001\u73fe\u5728\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304a\u3088\u3073\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u3067\u6587\u5b57\u5217\u3092\u691c\u7d22\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u691c\u7d22\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code>$ grep -r \"string-name\" *\r\n<\/code><\/pre>\n<p>\u305f\u3068\u3048\u3070<\/p>\n<pre class=\"post-pre\"><code>$ grep -r \"linux\" *\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/21-0.png\" alt=\"grep command usage example\" \/><\/div>\n<h2>\u5927\u6587\u5b57\u3068\u5c0f\u6587\u5b57\u306e\u533a\u5225\u3092\u7121\u8996\u3059\u308b\u3002<\/h2>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u691c\u7d22\u7d50\u679c\u304c\u5e0c\u671b\u901a\u308a\u306e\u3082\u306e\u3092\u63d0\u4f9b\u3057\u3066\u304f\u308c\u307e\u3057\u305f\u3002\u306a\u305c\u306a\u3089\u3070\u6587\u5b57\u5217\u300cLinux\u300d\u304c\u5927\u6587\u5b57\u3067\u6307\u5b9a\u3055\u308c\u3001\u30d5\u30a1\u30a4\u30eb\u5185\u306b\u3082\u5927\u6587\u5b57\u3067\u5b58\u5728\u3057\u3066\u3044\u305f\u304b\u3089\u3067\u3059\u3002\u3055\u3066\u3001\u6b21\u306f\u540c\u3058\u6587\u5b57\u5217\u3092\u5c0f\u6587\u5b57\u3067\u691c\u7d22\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"post-pre\"><code>$ grep \"linux\" file name\r\n<\/code><\/pre>\n<p>\u51fa\u529b\u306b\u306f\u4f55\u3082\u3042\u308a\u307e\u305b\u3093\u3088\u306d\uff1f\u3053\u308c\u306f\u3001\u6700\u521d\u306e\u6587\u5b57\u304c\u5c0f\u6587\u5b57\u3067\u3042\u308b\u305f\u3081\u3001grep\u304c\u6587\u5b57\u5217\u300clinux\u300d\u3092\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u305a\u306b\u4e00\u81f4\u3057\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u5927\u6587\u5b57\u3068\u5c0f\u6587\u5b57\u3092\u7121\u8996\u3059\u308b\u306b\u306f\u3001-i\u30d5\u30e9\u30b0\u3092\u4f7f\u7528\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code>$ grep -i \"linux\" welcome.txt\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/27-0.png\" alt=\"grep command usage examples\" \/><\/div>\n<h2>\u300c-c \u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u3001\u6587\u5b57\u5217\u304c\u4e00\u81f4\u3059\u308b\u884c\u306e\u6570\u3092\u6570\u3048\u3066\u304f\u3060\u3055\u3044\u3002\u300d<\/h2>\n<p>\u6307\u5b9a\u3057\u305f\u6587\u5b57\u5217\u30d1\u30bf\u30fc\u30f3\u304c\u51fa\u73fe\u307e\u305f\u306f\u5b58\u5728\u3059\u308b\u5168\u884c\u6570\u3092\u30ab\u30a6\u30f3\u30c8\u3059\u308b\u305f\u3081\u306b\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code>$ grep -c \"Linux\" welcome.txt\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/31-0.png\" alt=\"grep command usage examples\" \/><\/div>\n<h2>\u51fa\u529b\u3092\u53cd\u8ee2\u3059\u308b\u305f\u3081\u306bGrep\u3092\u4f7f\u7528\u3059\u308b\u3002<\/h2>\n<p>Grep\u306e\u51fa\u529b\u3092\u53cd\u8ee2\u3055\u305b\u308b\u306b\u306f\u3001-v\u30d5\u30e9\u30b0\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002-v\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u3001grep\u306b\u5bfe\u3057\u3066\u3001\u6307\u5b9a\u3055\u308c\u305f\u8868\u73fe\u3068\u4e00\u81f4\u3057\u306a\u3044\u3059\u3079\u3066\u306e\u884c\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u6307\u793a\u3057\u307e\u3059\u3002-v\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u3001grep\u306e\u51fa\u529b\u3092\u53cd\u8ee2\u3055\u305b\u308b\u305f\u3081\u3001\u4e00\u81f4\u3059\u308b\u884c\u3067\u306f\u306a\u304f\u3001\u4e00\u81f4\u3057\u306a\u3044\u3059\u3079\u3066\u306e\u884c\u3092\u8868\u793a\u3057\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u306b\u623b\u308a\u3001\u8868\u793a\u3055\u308c\u308b\u884c\u756a\u53f7\u3092\u6307\u5b9a\u3057\u307e\u3057\u3087\u3046\u3002Vim\u30a8\u30c7\u30a3\u30bf\u3067ESC\u30ad\u30fc\u3092\u62bc\u3057\u3001\u30b3\u30ed\u30f3\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code> set nu\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/35-0.png\" alt=\"grep command usage examples\" \/><\/div>\n<pre class=\"post-pre\"><code>$ grep -v \"Linux\" welcome.txt\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/37-0.png\" alt=\"grep command usage examples\" \/><\/div>\n<h2>\u691c\u7d22\u30d1\u30bf\u30fc\u30f3\u3092\u542b\u3080\u884c\u306b\u306f-n\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u884c\u756a\u53f7\u3092\u4ed8\u3051\u308b<\/h2>\n<p>\u6587\u5b57\u5217\u30d1\u30bf\u30fc\u30f3\u304c\u4e00\u81f4\u3059\u308b\u884c\u306b\u884c\u756a\u53f7\u3092\u4ed8\u3051\u308b\u305f\u3081\u306b\u3001-n\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code>$ grep -n \"Linux\" welcome.txt\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/41-0.png\" alt=\"grep command usage examples\" \/><\/div>\n<h2>-w\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3001\u5b8c\u5168\u4e00\u81f4\u3059\u308b\u5358\u8a9e\u3092\u691c\u7d22\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/h2>\n<p>\u305d\u306e\u5834\u5408\u3001-w\u30d5\u30e9\u30b0\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u8868\u793a\u3055\u308c\u308b\u5358\u8a9e\u3068\u5b8c\u5168\u306b\u4e00\u81f4\u3059\u308b\u884c\u3092\u691c\u7d22\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>$ grep -w \"opensource\" welcome.txt\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/45-0.png\" alt=\"grep command usage examples\" \/><\/div>\n<pre class=\"post-pre\"><code>$ grep -w \"open\" welcome.txt\r\n<\/code><\/pre>\n<p>\u30d1\u30bf\u30fc\u30f3\u3067\u306f\u306a\u304f\u3001\u6b63\u78ba\u306a\u5358\u8a9e\u3092\u691c\u7d22\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u7d50\u679c\u306f\u8fd4\u3055\u308c\u307e\u305b\u3093\uff01<\/p>\n<h2>grep\u3092\u4f7f\u7528\u3057\u3066\u30d1\u30a4\u30d7\u3092\u4f7f\u3046\u3002<\/h2>\n<p>grep\u30b3\u30de\u30f3\u30c9\u306f\u3001\u30d1\u30a4\u30d7\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u7279\u5b9a\u306e\u51fa\u529b\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001Ubuntu\u30b7\u30b9\u30c6\u30e0\u306b\u7279\u5b9a\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u77e5\u308a\u305f\u3044\u5834\u5408\u306f\u3001\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code>$ dpkg -L | grep \"package-name\"\r\n<\/code><\/pre>\n<p>\u4f8b\u3048\u3070\u3001OpenSSH\u304c\u30b7\u30b9\u30c6\u30e0\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u8abf\u3079\u308b\u305f\u3081\u306b\u3001dpkg -l\u30b3\u30de\u30f3\u30c9\u3092grep\u306b\u30d1\u30a4\u30d7\u3057\u3066\u8868\u793a\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>$ dpkg -L | grep -i \"openssh\"\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/53-0.png\" alt=\"grep command usage\" \/><\/div>\n<h2>\u691c\u7d22\u30d1\u30bf\u30fc\u30f3\u306e\u524d\u5f8c\u306b\u884c\u6570\u3092\u8868\u793a\u3059\u308b\u5834\u5408\u3001\u30d1\u30a4\u30d7\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/h2>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001\u691c\u7d22\u6587\u5b57\u5217\u306e\u524d\u307e\u305f\u306f\u5f8c\u306b\u8868\u793a\u3055\u308c\u308b\u884c\u306e\u6570\u3092\u6307\u5b9a\u3059\u308b\u305f\u3081\u306b\u3001-A\u307e\u305f\u306f-B\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002-A\u30d5\u30e9\u30b0\u306f\u691c\u7d22\u6587\u5b57\u5217\u306e\u5f8c\u306b\u8868\u793a\u3055\u308c\u308b\u884c\u3092\u793a\u3057\u3001-B\u306f\u691c\u7d22\u6587\u5b57\u5217\u306e\u524d\u306b\u8868\u793a\u3055\u308c\u308b\u51fa\u529b\u3092\u8868\u793a\u3057\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001<\/p>\n<pre class=\"post-pre\"><code>$ ifconfig | grep -A 4 ens3\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/57-0.png\" alt=\"grep usage commands\" \/><\/div>\n<pre class=\"post-pre\"><code>$ ifconfig | grep -B 4 ether\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/59-0.png\" alt=\"grep command usage\" \/><\/div>\n<h2>\u6b63\u898f\u8868\u73fe\uff08REGEX\uff09\u3092\u4f7f\u7528\u3057\u3066grep\u3092\u4f7f\u3046\u3002<\/h2>\n<p>\u300cREGEX\u300d\u3068\u3044\u3046\u7528\u8a9e\u306f\u3001REGular EXpression\u306e\u7565\u3067\u3059\u3002REGEX\u306f\u3001\u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3059\u308b\u6587\u5b57\u5217\u306e\u30b7\u30fc\u30b1\u30f3\u30b9\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3044\u304f\u3064\u304b\u306e\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>^      Matches characters at the beginning of a line\r\n$      Matches characters at the end of a line\r\n\".\"    Matches any character\r\n[a-z]  Matches any characters between A and Z\r\n[^ ..] Matches anything apart from what is contained in the brackets\r\n<\/code><\/pre>\n<p>\u3042\u308b\u7279\u5b9a\u306e\u6587\u5b57\u3067\u59cb\u307e\u308b\u884c\u3092\u5370\u5237\u3059\u308b\u305f\u3081\u306e\u69cb\u6587\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>grep ^character file_name\r\n<\/code><\/pre>\n<p>\u4f8b\u3048\u3070\u3001\u79c1\u305f\u3061\u306ewelcome.txt\u30d5\u30a1\u30a4\u30eb\u306e\u5148\u982d\u304c\u300cd\u300d\u3067\u59cb\u307e\u308b\u884c\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306b\u3001\u6b21\u306e\u3088\u3046\u306b\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>$ grep ^d welcome.txt \r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/67-0.png\" alt=\"grep regex example\" \/><\/div>\n<pre class=\"post-pre\"><code>$ grep x$ welcome.txt\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/69-0.png\" alt=\"grep regex end of line\" \/><\/div>\n<h2>\u3088\u308a\u591a\u304f\u306eGrep\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u652f\u63f4\u3092\u53d7\u3051\u308b<\/h2>\n<p>\u3082\u3057Grep\u30b3\u30de\u30f3\u30c9\u306e\u4f7f\u7528\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3082\u3063\u3068\u5b66\u3073\u305f\u3044\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001\u30b3\u30de\u30f3\u30c9\u3068\u4e00\u7dd2\u306b\u4f7f\u7528\u3067\u304d\u308b\u4ed6\u306e\u30d5\u30e9\u30b0\u3084\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u4e00\u90e8\u3092\u4e8b\u524d\u306b\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>$ grep --help\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/73-0.png\" alt=\"grep command usage\" \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u3084Unix\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u3001Grep\u3068\u3044\u3046\u30b3\u30de\u30f3\u30c9\u304c\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002Grep\u306f\u300c\u30b0\u30ed\u30fc\u30d0\u30eb\u6b63\u898f\u8868\u73fe\u30d7\u30ea\u30f3\u30c8\u300d\u3068\u3044\u3046\u610f\u5473\u3067\u3001\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u691c\u7d22\u304a\u3088\u3073\u30de\u30c3\u30c1\u30f3\u30b0\u3059\u308b\u305f\u3081\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3059\u3002\u3055\u3089\u306b\u3001\u3053\u306e [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,61],"class_list":["post-712","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-26","tag-61"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix\u306b\u304a\u3051\u308bgrep\u30b3\u30de\u30f3\u30c9\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9\" \/>\n<meta property=\"og:description\" content=\"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix\u306b\u304a\u3051\u308bgrep\u30b3\u30de\u30f3\u30c9\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-27T06:34:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T16:51:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/10-0.png\" \/>\n<meta name=\"author\" content=\"\u5149, \u660e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5149, \u660e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"11\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/\",\"name\":\"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2022-12-27T06:34:20+00:00\",\"dateModified\":\"2025-07-31T16:51:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/9ee62cea876d247deba14a0ac7ba5b55\"},\"description\":\"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/9ee62cea876d247deba14a0ac7ba5b55\",\"name\":\"\u5149, \u660e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3dffb6c754b95e3fbdcd8973f4375ff9dd10d41e4f6632ad08d4d59ccc35af8d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3dffb6c754b95e3fbdcd8973f4375ff9dd10d41e4f6632ad08d4d59ccc35af8d?s=96&d=mm&r=g\",\"caption\":\"\u5149, \u660e\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/hikariakira\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9 - Blog - Silicon Cloud","description":"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix\u306b\u304a\u3051\u308bgrep\u30b3\u30de\u30f3\u30c9\/","og_locale":"ja_JP","og_type":"article","og_title":"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9","og_description":"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix\u306b\u304a\u3051\u308bgrep\u30b3\u30de\u30f3\u30c9\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-12-27T06:34:20+00:00","article_modified_time":"2025-07-31T16:51:48+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649697daa94e2bdf7bfd93\/10-0.png"}],"author":"\u5149, \u660e","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u5149, \u660e","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"11\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/","name":"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2022-12-27T06:34:20+00:00","dateModified":"2025-07-31T16:51:48+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/9ee62cea876d247deba14a0ac7ba5b55"},"description":"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"Linux\/UNIX\u306b\u304a\u3051\u308bGrep\u30b3\u30de\u30f3\u30c9"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/9ee62cea876d247deba14a0ac7ba5b55","name":"\u5149, \u660e","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3dffb6c754b95e3fbdcd8973f4375ff9dd10d41e4f6632ad08d4d59ccc35af8d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3dffb6c754b95e3fbdcd8973f4375ff9dd10d41e4f6632ad08d4d59ccc35af8d?s=96&d=mm&r=g","caption":"\u5149, \u660e"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/hikariakira\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/linux-unix%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bgrep%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=712"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/712\/revisions"}],"predecessor-version":[{"id":44067,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/712\/revisions\/44067"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}