Next: , Previous: Reverse chars of lines, Up: Examples   [Contents][Index]


4.6 ¥Õ¥¡¥¤¥ë¤Î¹Ô¤òȿž¤¹¤ë

°Ê²¼¤Î¤â¤Î¤Ï¡¤ÍÍ¡¹¤ÊUnix¥³¥Þ¥ó¥É¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ëÁ´¤¯°ÕÌ£¤¬¤Ê¤¤(ÌÌÇò¤¤ ¤±¤É¤Í)¥¹¥¯¥ê¥×¥È¤Ç¤¹¡¥¤³¤ì¤ÏÆÃ¤Ëtac¤ÈƱÅù¤Îưºî¤ò¤·¤Þ¤¹¡¥

GNU sed¤ÈGNU sed°Ê³°¤Î¼ÂÁõ¤Ç¤Ï¡¤ ¤³¤Î¥¹¥¯¥ê¥×¥È¤Ï´Êñ¤ËÆâÉô¥Ð¥Ã¥Õ¥¡¤Ç¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤¹¤ë²ÄǽÀ­¤¬¤¢¤ë¤³¤È ¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡¥

#!/usr/bin/sed -nf

# reverse all lines of input, i.e. first line became last, ...

# from the second line, the buffer (which contains all previous lines)
# is *appended* to current line, so, the order will be reversed
1! G
# on the last line we're done -- print everything
$ p
# store everything on the buffer again
h