edコマンドを使いこなせるとかっこいいです。
使い方を少しずつまとめていきたいと思います。
Contents
edコマンド入門
edのインストール
takk~$ apt install ed
edの起動
edと入力して、Enterを押すだけです。
takk~$ ed
何も表示されませんが、これで立派に動いています。
edの終了
takk~$ ed q takk~$
強制終了は、Qを使います。
takk~$ ed Q takk~$
edのプロンプト表示・非表示切替
Pコマンドは、プロンプトの表示・非表示を切り替えます。
takk~$ ed P *
トグル切り替えなので、もう一度Pコマンドを実行すると、非表示になります。
takk~$ ed P *P
外部コマンドの実行
r !コマンドで、コマンドの実行結果をバッファに読み込むことができます。
takk~$ ed r !seq -s- 10 21
これでバッファにseqコマンドの結果が読み込まれました。
現在のバッファの内容を表示してみます。
takk~$ ed r !seq -s- 10 21 ,p 1-2-3-4-5-6-7-8-9-10
プロンプトを変更する
Pでは分かりづらいので、起動時の-pオプションで変更してみます。
takk~$ ed -p'>>>' >>>
プロンプトを非表示にするには、Pコマンドを実行すればよいです。
>>>P
a テキストを入力
aコマンドで、テキスト入力を開始します。終了は、.(ピリオド)です。
takk~$ ed -p'>>>' >>>a AAAA BBBB CCCC DDDD EEEE . >>>
l 編集中のテキストの表示
lコマンドで編集中テキストを表示できます。
アドレスを,(カンマ)だけにすれば全テキストを表示します。
>>>,l AAAA$ BBBB$ CCCC$ DDDD$ EEEE$ >>>
w ファイル名をつけて保存
>>>,l
AAAA$
BBBB$
CCCC$
DDDD$
EEEE$
>>>w tmp.txt
25
>>>q
takk~$ cat -n
^C
takk~$ cat -n tmp.txt
1 AAAA
2 BBBB
3 CCCC
4 DDDD
5 EEEE
takk~$
edコマンドのmanの表示
(man ed全文)
ED(1) User Commands ED(1)
NAME
ed - line-oriented text editor
SYNOPSIS
ed [options] [file]
DESCRIPTION
GNU ed is a line-oriented text editor. It is used to create, display,
modify and otherwise manipulate text files, both interactively and via
shell scripts. A restricted version of ed, red, can only edit files in
the current directory and cannot execute shell commands. Ed is the
'standard' text editor in the sense that it is the original editor for
Unix, and thus widely available. For most purposes, however, it is su‐
perseded by full-screen editors such as GNU Emacs or GNU Moe.
OPTIONS
-h, --help
display this help and exit
-V, --version
output version information and exit
-G, --traditional
run in compatibility mode
-l, --loose-exit-status
exit with 0 status even if a command fails
-p, --prompt=STRING
use STRING as an interactive prompt
-r, --restricted
run in restricted mode
-s, --quiet, --silent
suppress diagnostics, byte counts and '!' prompt
-v, --verbose
be verbose; equivalent to the 'H' command
Start edit by reading in 'file' if given. If 'file' begins with a '!',
read output of shell command.
Exit status: 0 for a normal exit, 1 for environmental problems (file
not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or
invalid input file, 3 for an internal consistency error (eg, bug) which
caused ed to panic.
REPORTING BUGS
Report bugs to bug-ed@gnu.org
Ed home page: http://www.gnu.org/software/ed/ed.html
General help using GNU software: http://www.gnu.org/gethelp
COPYRIGHT
Copyright © 1994 Andrew L. Moore.
Copyright © 2019 Antonio Diaz Diaz. License GPLv3+: GNU GPL version 3
or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
The full documentation for ed is maintained as a Texinfo manual. If
the info and ed programs are properly installed at your site, the com‐
mand
info ed
should give you access to the complete manual.
ed 1.15 January 2019 ED(1)
本記事は書き始めです。


コメント