Next: , Up: Examples   [Contents][Index]


4.1 ¹Ô¤ÎÃæ±û·¤¨

°Ê²¼¤Î¥¹¥¯¥ê¥×¥È¤Ï¡¤¥Õ¥¡¥¤¥ë¤Î¤¹¤Ù¤Æ¤Î¹Ô¤ò80·å¤ÎÉý¤Ç¥»¥ó¥¿¥ê¥ó¥°¤·¤Þ¤¹¡¥ Éý¤òÊѹ¹¤¹¤ë¤¿¤á¡¤\{…\}¤Î¿ôÃͤòÊѹ¹¤¹¤ëɬÍפ¬¤¢¤ê¡¤Äɲà ¤µ¤ì¤ë¥¹¥Ú¡¼¥¹¤âÊѹ¹¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡¥

¥Þ¥Ã¥Á¤µ¤»¤ëÀµµ¬É½¸½¤ÎÉôʬ¤òʬΥ¤¹¤ë¤¿¤á¡¤¥Ð¥Ã¥Õ¥¡¥³¥Þ¥ó¥É¤¬»ÈÍѤµ¤ì¤Æ ¤¤¤ëÊýË¡¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤ — ¤³¤ì¤Ï°ìÈÌŪ¤Ê¥Æ¥¯¥Ë¥Ã¥¯¤Ç¤¹¡¥

#!/usr/bin/sed -f

# Put 80 spaces in the buffer
1 {
  x
  s/^$/          /
  s/^.*$/&&&&&&&&/
  x
}
# del leading and trailing spaces
y/tab/ /
s/^ *//
s/ *$//
# add a newline and 80 spaces to end of line
G
# keep first 81 chars (80 + a newline)
s/^\(.\{81\}\).*$/\1/
# \2 matches half of the spaces, which are moved to the beginning
s/^\(.*\)\n\(.*\)\2/\2\1/