Как я могу автоматически генерировать имя файла для gnome-screenshot?

Вывод команды head -n 1 /etc/mailname должен быть вашим доменом, например example.com.

Если вывод похож на mail.example.com, это ошибка.

Итак, вы можете исправить это, изменив файл /etc/amavis/conf.d/05-domain_id

, это ошибка

Внутри /etc/amavis/conf.d/05-domain_id:

Изменить: [ ! d7]

    chomp($mydomain = `head -n 1 /etc/mailname`);

To:

    chomp($mydomain = `hostname -d`);

PS: Выход из hostname -d должен быть вашим доменом, например example.com.

Самое простое решение, :

Внутри /etc/amavis/conf.d/05-domain_id:

Изменить:

    chomp($mydomain = `head -n 1 /etc/mailname`);

Кому:

    $mydomain = "example.com";
1
задан 8 December 2017 в 00:06

3 ответа

Вы можете использовать команду date для задания включения фактической даты и времени в имя файла. Посмотрим, что мы найдем на странице date man:

OPERANDS
   The following operands shall be supported:

   +format   When the format is specified, each conversion specifier shall
             be replaced in  the  standard  output  by  its  corresponding
             value.  All  other  characters  shall be copied to the output
             without change. The output shall always be terminated with  a
             <newline>.
Спецификации конверсий% сокращенное название недели в Locale.
             %A      Locale's full weekday name.

             %b      Locale's abbreviated month name.

             %B      Locale's full month name.

             %c      Locale's appropriate date and time representation.

             %C      Century  (a  year  divided by 100 and truncated to an
                     integer) as a decimal number [00,99].

             %d      Day of the month as a decimal number [01,31].

             %D      Date in the format mm/dd/yy.

             %e      Day of the month as a decimal number [1,31] in a two-
                     digit field with leading <space> character fill.

             %h      A synonym for %b.

             %H      Hour (24-hour clock) as a decimal number [00,23].

             %I      Hour (12-hour clock) as a decimal number [01,12].

             %j      Day of the year as a decimal number [001,366].

             %m      Month as a decimal number [01,12].

             %M      Minute as a decimal number [00,59].

             %n      A <newline>.

             %p      Locale's equivalent of either AM or PM.

             %r      12-hour  clock time [01,12] using the AM/PM notation;
                     in the POSIX locale,  this  shall  be  equivalent  to
                     %I:%M:%S %p.

             %S      Seconds as a decimal number [00,60].

             %t      A <tab>.

             %T      24-hour clock time [00,23] in the format HH:MM:SS.

             %u      Weekday as a decimal number [1,7] (1=Monday).

             %U      Week  of  the  year  (Sunday  as the first day of the
                     week) as a decimal number [00,53]. All days in a  new
                     year  preceding  the first Sunday shall be considered
                     to be in week 0.

             %V      Week of the year (Monday as  the  first  day  of  the
                     week)  as  a  decimal  number  [01,53].  If  the week
                     containing January 1 has four or more days in the new
                     year,  then it shall be considered week 1; otherwise,
                     it shall be the last week of the previous  year,  and
                     the next week shall be week 1.

             %w      Weekday as a decimal number [0,6] (0=Sunday).

             %W      Week  of  the  year  (Monday  as the first day of the
                     week) as a decimal number [00,53]. All days in a  new
                     year  preceding  the first Monday shall be considered
                     to be in week 0.

             %x      Locale's appropriate date representation.

             %X      Locale's appropriate time representation.

             %y      Year within century [00,99].

             %Y      Year with century as a decimal number.

             %Z      Timezone name, or no characters  if  no  timezone  is
                     determinable.

             %%      A <percent-sign> character.

             See  the  Base  Definitions  volume  of POSIX.1‐2008, Section
             7.3.5, LC_TIME for the conversion  specifier  values  in  the
             POSIX locale.

Поскольку date не может содержать пробелы, отформатированные в его выводе, вам нужно будет использовать две команды даты, как показано ниже, сначала для даты, когда вы можете использовать +\%Y.\%m.\%d в качестве параметра, который приведет к в формате даты, например 2017.12.07, и за время, которое вы можете использовать +\%H:\%M:\%S, что приведет к формату, например 20:37:18.

Вариант буфера обмена (-c) не работает вместе с сохранить как параметр имени файла (-f) в gnome-screenshot, поэтому вам нужно выбрать один из них. Эта команда выполнит это (просто отредактируйте c назад, если вам нужен буфер обмена, но затем пусть f и имя файла, оба будут работать вместе):

gnome-screenshot -af "Screenshot from $(date +\%Y.\%m.\%d) $(date +\%H:\%M:\%S).png"

Он генерирует имя файла, подобное следующему (только с фактической датой и временем, когда вы вызываете эту команду):

Screenshot from 2017.12.07 20:37:18.png

Однако это сохранит файл в каталоге, в котором вы сейчас находитесь, чтобы добавить путь, например ~/Pictures вам нужно предоставить полный путь, так как ~ не будет расширяться внутри кавычек. Следующие файлы сохранили бы файлы, например, в папке с фотографиями:

gnome-screenshot -af "/home/$USER/Pictures/Screenshot from $(date +\%Y.\%m.\%d) $(date +\%H:\%M:\%S).png"

Или вы избавитесь от кавычек, которые тогда означают, что вы можете использовать тильду (~), но тогда вам нужно убежать все пробелы в названии:

gnome-screenshot -af ~/Pictures/Screenshot\ from\ $(date +\%Y.\%m.\%d)\ $(date +\%H:\%M:\%S).png

См. date справочную страницу и man gnome-screenshot, а также справочное руководство Bash для более подробной информации.

1
ответ дан 22 May 2018 в 15:34
  • 1
    Ницца! Это хранится в ~. Можем ли мы поместить его в ~/Pictures? – orschiro 7 December 2017 в 23:44
  • 2
    @orschiro Да, вы можете добавить путь слишком , но он не будет копировать в буфер обмена одновременно. – pomsky 7 December 2017 в 23:46
  • 3
    По некоторым причинам, это один из них. [F1]. – orschiro 7 December 2017 в 23:46
  • 4
    @orschiro Попробуйте gnome-screenshot -af ~/Pictures/Screenshot\ from\ $(date +\%Y.\%m.\%d)\ $(date +\%H:\%M:\%S).png. – pomsky 7 December 2017 в 23:53
  • 5
    Отлично! Кажется, что вы не можете одновременно использовать -cf. Можешь подтвердить? – orschiro 8 December 2017 в 00:06

Вы можете использовать команду date для задания включения фактической даты и времени в имя файла. Посмотрим, что мы найдем на странице date man:

OPERANDS The following operands shall be supported: +format When the format is specified, each conversion specifier shall be replaced in the standard output by its corresponding value. All other characters shall be copied to the output without change. The output shall always be terminated with a <newline>. Спецификации конверсий% сокращенное название недели в Locale. %A Locale's full weekday name. %b Locale's abbreviated month name. %B Locale's full month name. %c Locale's appropriate date and time representation. %C Century (a year divided by 100 and truncated to an integer) as a decimal number [00,99]. %d Day of the month as a decimal number [01,31]. %D Date in the format mm/dd/yy. %e Day of the month as a decimal number [1,31] in a two- digit field with leading <space> character fill. %h A synonym for %b. %H Hour (24-hour clock) as a decimal number [00,23]. %I Hour (12-hour clock) as a decimal number [01,12]. %j Day of the year as a decimal number [001,366]. %m Month as a decimal number [01,12]. %M Minute as a decimal number [00,59]. %n A <newline>. %p Locale's equivalent of either AM or PM. %r 12-hour clock time [01,12] using the AM/PM notation; in the POSIX locale, this shall be equivalent to %I:%M:%S %p. %S Seconds as a decimal number [00,60]. %t A <tab>. %T 24-hour clock time [00,23] in the format HH:MM:SS. %u Weekday as a decimal number [1,7] (1=Monday). %U Week of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday shall be considered to be in week 0. %V Week of the year (Monday as the first day of the week) as a decimal number [01,53]. If the week containing January 1 has four or more days in the new year, then it shall be considered week 1; otherwise, it shall be the last week of the previous year, and the next week shall be week 1. %w Weekday as a decimal number [0,6] (0=Sunday). %W Week of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday shall be considered to be in week 0. %x Locale's appropriate date representation. %X Locale's appropriate time representation. %y Year within century [00,99]. %Y Year with century as a decimal number. %Z Timezone name, or no characters if no timezone is determinable. %% A <percent-sign> character. See the Base Definitions volume of POSIX.1‐2008, Section 7.3.5, LC_TIME for the conversion specifier values in the POSIX locale.

Поскольку date не может содержать пробелы, отформатированные в его выводе, вам нужно будет использовать две команды даты, как показано ниже, сначала для даты, когда вы можете использовать +\%Y.\%m.\%d в качестве параметра, который приведет к в формате даты, например 2017.12.07, и за время, которое вы можете использовать +\%H:\%M:\%S, что приведет к формату, например 20:37:18.

Вариант буфера обмена (-c) не работает вместе с сохранить как параметр имени файла (-f) в gnome-screenshot, поэтому вам нужно выбрать один из них. Эта команда выполнит это (просто отредактируйте c назад, если вам нужен буфер обмена, но затем пусть f и имя файла, оба будут работать вместе):

gnome-screenshot -af "Screenshot from $(date +\%Y.\%m.\%d) $(date +\%H:\%M:\%S).png"

Он генерирует имя файла, подобное следующему (только с фактической датой и временем, когда вы вызываете эту команду):

Screenshot from 2017.12.07 20:37:18.png

Однако это сохранит файл в каталоге, в котором вы сейчас находитесь, чтобы добавить путь, например ~/Pictures вам нужно предоставить полный путь, так как ~ не будет расширяться внутри кавычек. Следующие файлы сохранили бы файлы, например, в папке с фотографиями:

gnome-screenshot -af "/home/$USER/Pictures/Screenshot from $(date +\%Y.\%m.\%d) $(date +\%H:\%M:\%S).png"

Или вы избавитесь от кавычек, которые тогда означают, что вы можете использовать тильду (~), но тогда вам нужно убежать все пробелы в названии:

gnome-screenshot -af ~/Pictures/Screenshot\ from\ $(date +\%Y.\%m.\%d)\ $(date +\%H:\%M:\%S).png

См. date справочную страницу и man gnome-screenshot, а также справочное руководство Bash для более подробной информации.

1
ответ дан 18 July 2018 в 01:38

Вы можете использовать команду date для задания включения фактической даты и времени в имя файла. Посмотрим, что мы найдем на странице date man:

OPERANDS The following operands shall be supported: +format When the format is specified, each conversion specifier shall be replaced in the standard output by its corresponding value. All other characters shall be copied to the output without change. The output shall always be terminated with a <newline>. Спецификации конверсий% сокращенное название недели в Locale. %A Locale's full weekday name. %b Locale's abbreviated month name. %B Locale's full month name. %c Locale's appropriate date and time representation. %C Century (a year divided by 100 and truncated to an integer) as a decimal number [00,99]. %d Day of the month as a decimal number [01,31]. %D Date in the format mm/dd/yy. %e Day of the month as a decimal number [1,31] in a two- digit field with leading <space> character fill. %h A synonym for %b. %H Hour (24-hour clock) as a decimal number [00,23]. %I Hour (12-hour clock) as a decimal number [01,12]. %j Day of the year as a decimal number [001,366]. %m Month as a decimal number [01,12]. %M Minute as a decimal number [00,59]. %n A <newline>. %p Locale's equivalent of either AM or PM. %r 12-hour clock time [01,12] using the AM/PM notation; in the POSIX locale, this shall be equivalent to %I:%M:%S %p. %S Seconds as a decimal number [00,60]. %t A <tab>. %T 24-hour clock time [00,23] in the format HH:MM:SS. %u Weekday as a decimal number [1,7] (1=Monday). %U Week of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday shall be considered to be in week 0. %V Week of the year (Monday as the first day of the week) as a decimal number [01,53]. If the week containing January 1 has four or more days in the new year, then it shall be considered week 1; otherwise, it shall be the last week of the previous year, and the next week shall be week 1. %w Weekday as a decimal number [0,6] (0=Sunday). %W Week of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday shall be considered to be in week 0. %x Locale's appropriate date representation. %X Locale's appropriate time representation. %y Year within century [00,99]. %Y Year with century as a decimal number. %Z Timezone name, or no characters if no timezone is determinable. %% A <percent-sign> character. See the Base Definitions volume of POSIX.1‐2008, Section 7.3.5, LC_TIME for the conversion specifier values in the POSIX locale.

Поскольку date не может содержать пробелы, отформатированные в его выводе, вам нужно будет использовать две команды даты, как показано ниже, сначала для даты, когда вы можете использовать +\%Y.\%m.\%d в качестве параметра, который приведет к в формате даты, например 2017.12.07, и за время, которое вы можете использовать +\%H:\%M:\%S, что приведет к формату, например 20:37:18.

Вариант буфера обмена (-c) не работает вместе с сохранить как параметр имени файла (-f) в gnome-screenshot, поэтому вам нужно выбрать один из них. Эта команда выполнит это (просто отредактируйте c назад, если вам нужен буфер обмена, но затем пусть f и имя файла, оба будут работать вместе):

gnome-screenshot -af "Screenshot from $(date +\%Y.\%m.\%d) $(date +\%H:\%M:\%S).png"

Он генерирует имя файла, подобное следующему (только с фактической датой и временем, когда вы вызываете эту команду):

Screenshot from 2017.12.07 20:37:18.png

Однако это сохранит файл в каталоге, в котором вы сейчас находитесь, чтобы добавить путь, например ~/Pictures вам нужно предоставить полный путь, так как ~ не будет расширяться внутри кавычек. Следующие файлы сохранили бы файлы, например, в папке с фотографиями:

gnome-screenshot -af "/home/$USER/Pictures/Screenshot from $(date +\%Y.\%m.\%d) $(date +\%H:\%M:\%S).png"

Или вы избавитесь от кавычек, которые тогда означают, что вы можете использовать тильду (~), но тогда вам нужно убежать все пробелы в названии:

gnome-screenshot -af ~/Pictures/Screenshot\ from\ $(date +\%Y.\%m.\%d)\ $(date +\%H:\%M:\%S).png

См. date справочную страницу и man gnome-screenshot, а также справочное руководство Bash для более подробной информации.

1
ответ дан 24 July 2018 в 17:25

Другие вопросы по тегам:

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