Как добавить строку темы при отправке электронного письма с выводом find с помощью ssmtp

Обязательное решение sed

Следующий GNU sed программа использует цикл для перемещения каждого слова (начиная с первого) в конец строки. Более подробная информация вставлена ​​в код в виде комментариев.

sed -r '
    # Mark the current end of the line by appending a LF character ("\n")
    G

    # Main loop: move the first word of the line just after the LF
    # and repeat until the LF is at the beginning of the line
    :loop
    s/([^[:space:]]+)(.*\n)/\2\1 /
    t loop

    # Remove remaining spaces up to the LF and the superfluous trailing space
    s/.*\n| $//g
'

Версия только для записи:

sed -r 'G; :loop; s/(\S+)(.*\n)/\2\1 /; t loop; s/.*\n| $//g'

Тест:

$ sed -r '...' <<< "The quick
brown fox jumps

over
the lazy dog"

... дает:

quick The 
jumps fox brown 

over 
dog lazy the 

Переносимость (POSIXly):

sed '
  G
  :loop
     s/\([^[:space:]]\{1,\}\)\(.*\n\)/\2\1 /
  t loop
  s/ $//
  s/.*\n//'
1
20.11.2015, 10:48
0 ответов

Теги

Похожие вопросы