ナビゲーション
FrontPage
FreeBSD
Linux
Citrix XenServer
VMware ESXi
Unixコマンド
MySQL
PostgreSQL
Windows
CMS/CRM
クラウド
用語
PHPスクリプト
Bashシェルスクリプト
Rubyスクリプト
開発日記
検索
ツールボックス
新しいページの作成
バックアップの表示
外部のリンク元
最近更新したページ
全ページ
ヘルプ
凍結
アップロード
ページ名の変更
最新の40件
2016-08-17
Linux/NagiosQL
Linux/CentOSチューニング
2016-02-23
Linux/ソフトウェアRAID復旧手順
2016-02-18
FreeBSD/DHCP
FreeBSD/squid
2016-02-15
Unixコマンド/file
2016-02-05
FreeBSD/DynaBook
FreeBSD/Linux compatibility
2016-01-21
PHPスクリプト/PEAR DBインストールできない
PHPスクリプト/PEAR DB
2016-01-20
PHP/フレームワーク/Zend Framework
PHP/フレームワーク
FreeBSD/Postfix+amavisd+clamav
2016-01-15
FreeBSD/sl
2015-12-04
Unixコマンド/dig
Unixコマンド/nslookup
Unixコマンド/traceroute
Linux/rsync
FreeBSD/rsync
Unixコマンド/vipw
2015-11-25
Linux/Postfix+MySQL+Postfix AdminによるバーチャルSMTPサーバの構築
Linux/Postfix + postgrey
2015-11-24
Linux/Postfix + amavisd + clamav
2015-05-25
Unixコマンド/ifconfig
2015-05-23
Unixコマンド/netstat
Unixコマンド/route
Unixコマンド/lsof
Unixコマンド/disown
Unixコマンド/time
Unixコマンド/crontab
2015-05-22
Unixコマンド/nohup
Unixコマンド/fgとbg
Unixコマンド/nice
Unixコマンド/kill
Unixコマンド/jobs
Unixコマンド/restor
Unixコマンド/dump
Unixコマンド/uncompress
Unixコマンド/compress
Unixコマンド/zcat
total:
2076
today:
1
yesterday:
0
now:
1
本文
ノート
?
編集
差分
一覧
Unixコマンド/grep の編集
*&size(15){''grep''}; [#d428478f] **''機能'' [#j45aee58] grepコマンドは、指定されたパターン(文字列)を含む行を抽出し、結果を標準出力に出力します。~ ファイル名が指定されない場合は、標準入力からデータを読み込みます。~ ファイル名はワイルドカードなどを用いて一度に複数のファイルを指定できます。~ パターンには正規表現が指定できます。~ **''形式'' [#g127532b] grep [オプション] [パターン] [ファイル名] **''オプション'' [#l00307a3] -e このオプションに続く引数をパターンとして処理 (-から始まるパターンを指定したいときに使用) -h 複数のファイルを指定された場合でも、抽出した行の先頭にファイル名を表示しない -i パターンとの照合を行うときに、大文字小文字の区別をしない。 -n パターンを含む行がそのファイルに何行あるかを表示する。 -v 指定したパターンを含まない行を表示する。 -B1 指定したパターンを含む行と、その前1行を表示する。 -A1 指定したパターンを含む行と、その後一行を表示する。 **''コマンド例'' [#n057ca09] ▼指定した文字列を含む行を抽出~ /etc/shellsからlocalを含む行を抽出~ $ cat /etc/shells /etc/shellsの内容を表示する。 ------------------------------------------------- # $FreeBSD: src/etc/shells,v 1.3.2.1 2000/07/10 08:47:17 obrien Exp $ # # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using # one of these shells. /bin/sh /bin/csh /bin/tcsh /usr/local/bin/bash ------------------------------------------------- $ grep local /etc/shells /usr/local/bin/bash ▼指定した文字列を含まない行を表示する。~ /etc/shellsからlocalを含まない行を表示する。~ $ grep -v local /etc/shells # $FreeBSD: src/etc/shells,v 1.3.2.1 2000/07/10 08:47:17 obrien Exp $ # # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using # one of these shells. /bin/sh /bin/csh /bin/tcsh ▼正規表現を利用して、ある条件の文字列を抽出~ /etc/shellsから行の先頭が/binで始まる行を抽出する。 $ grep -e ^/bin /etc/shells /bin/sh /bin/csh /bin/tcsh ▼指定したパターンの前2行を表示する。 $ cat /etc/passwd ---------------------------------------------- root:*:0:0:Charlie &:/root:/bin/csh toor:*:0:0:Bourne-again Superuser:/root: daemon:*:1:1:Owner of many system processes:/root:/usr/sbin/nologin operator:*:2:5:System &:/:/usr/sbin/nologin bin:*:3:7:Binaries Commands and Source:/:/usr/sbin/nologin tty:*:4:65533:Tty Sandbox:/:/usr/sbin/nologin kmem:*:5:65533:KMem Sandbox:/:/usr/sbin/nologin games:*:7:13:Games pseudo-user:/usr/games:/usr/sbin/nologin news:*:8:8:News Subsystem:/:/usr/sbin/nologin ---------------------------------------------- $ grep -B2 operator /etc/passwd toor:*:0:0:Bourne-again Superuser:/root: daemon:*:1:1:Owner of many system processes:/root:/usr/sbin/nologin operator:*:2:5:System &:/:/usr/sbin/nologin
タイムスタンプを変更しない
*&size(15){''grep''}; [#d428478f] **''機能'' [#j45aee58] grepコマンドは、指定されたパターン(文字列)を含む行を抽出し、結果を標準出力に出力します。~ ファイル名が指定されない場合は、標準入力からデータを読み込みます。~ ファイル名はワイルドカードなどを用いて一度に複数のファイルを指定できます。~ パターンには正規表現が指定できます。~ **''形式'' [#g127532b] grep [オプション] [パターン] [ファイル名] **''オプション'' [#l00307a3] -e このオプションに続く引数をパターンとして処理 (-から始まるパターンを指定したいときに使用) -h 複数のファイルを指定された場合でも、抽出した行の先頭にファイル名を表示しない -i パターンとの照合を行うときに、大文字小文字の区別をしない。 -n パターンを含む行がそのファイルに何行あるかを表示する。 -v 指定したパターンを含まない行を表示する。 -B1 指定したパターンを含む行と、その前1行を表示する。 -A1 指定したパターンを含む行と、その後一行を表示する。 **''コマンド例'' [#n057ca09] ▼指定した文字列を含む行を抽出~ /etc/shellsからlocalを含む行を抽出~ $ cat /etc/shells /etc/shellsの内容を表示する。 ------------------------------------------------- # $FreeBSD: src/etc/shells,v 1.3.2.1 2000/07/10 08:47:17 obrien Exp $ # # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using # one of these shells. /bin/sh /bin/csh /bin/tcsh /usr/local/bin/bash ------------------------------------------------- $ grep local /etc/shells /usr/local/bin/bash ▼指定した文字列を含まない行を表示する。~ /etc/shellsからlocalを含まない行を表示する。~ $ grep -v local /etc/shells # $FreeBSD: src/etc/shells,v 1.3.2.1 2000/07/10 08:47:17 obrien Exp $ # # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using # one of these shells. /bin/sh /bin/csh /bin/tcsh ▼正規表現を利用して、ある条件の文字列を抽出~ /etc/shellsから行の先頭が/binで始まる行を抽出する。 $ grep -e ^/bin /etc/shells /bin/sh /bin/csh /bin/tcsh ▼指定したパターンの前2行を表示する。 $ cat /etc/passwd ---------------------------------------------- root:*:0:0:Charlie &:/root:/bin/csh toor:*:0:0:Bourne-again Superuser:/root: daemon:*:1:1:Owner of many system processes:/root:/usr/sbin/nologin operator:*:2:5:System &:/:/usr/sbin/nologin bin:*:3:7:Binaries Commands and Source:/:/usr/sbin/nologin tty:*:4:65533:Tty Sandbox:/:/usr/sbin/nologin kmem:*:5:65533:KMem Sandbox:/:/usr/sbin/nologin games:*:7:13:Games pseudo-user:/usr/games:/usr/sbin/nologin news:*:8:8:News Subsystem:/:/usr/sbin/nologin ---------------------------------------------- $ grep -B2 operator /etc/passwd toor:*:0:0:Bourne-again Superuser:/root: daemon:*:1:1:Owner of many system processes:/root:/usr/sbin/nologin operator:*:2:5:System &:/:/usr/sbin/nologin
テキスト整形のルールを表示する
ログインまたはアカウント作成