Удаление дат из файла CSV

Самый простой способ установить Ubuntu на 32-разрядный UEFI:

Сделать загрузочный USB-файл из Debian netinstall iso (он поддерживает 32-разрядную загрузку) с помощью unetbootin. Используя unetbootin, перезапишите созданный usb с помощью ubuntu iso. (вам это не нужно, но в моем случае я должен был это сделать) загрузите в оболочку UEFI, выберите диск (путем ввода «fsX:», где X - номер вашего диска), cd для EFI / BOOT и запустить bootia32.efi
0
задан 25 September 2017 в 02:24

4 ответа

Регулярные выражения делают эту проблему простой. Первая версия выводит даты на или после 2017-9-01.

grep -E "2017-([9]|[0-1][0-9])" file > output_file

Этот второй пример дополнительно фильтрует выход для исключения дат до 2017-9-15. Но только если день месяца равен нулю.

grep -E "2017-([9]|[0-1][0-9])-([0-9]|[0-9][0-9])" file | grep -Ev "2017-9-(0[0-9]|[0-1][0-5])" > output_file

Каждая пара квадратных скобок представляет собой одну цифру. Символ | означает или в регулярном выражении. См. Bash Guide for Beginners Chapter 4. Регулярные выражения для более подробной информации.

1
ответ дан 18 July 2018 в 06:16

Вы можете использовать dategrep. Из perldoc /usr/local/bin/dategrep:

NAME dategrep - print lines matching a date range SYNOPSIS dategrep --start "12:00" --end "12:15" --format "%b %d %H:%M:%S" syslog dategrep --end "12:15" --format "%b %d %H:%M:%S" syslog dategrep --last-minutes 5 --format "%b %d %H:%M:%S" syslog dategrep --last-minutes 5 --format rsyslog syslog cat syslog | dategrep --end "12:15" DESCRIPTION Do you even remember how often in your life you needed to find lines in a log file falling in a date range? And how often you build brittle regexs in grep to match entries spanning over a hour change? dategrep hopes to solve this problem once and for all.

...

INSTALLATION It is possible to install this script via perl normal install routines. perl Makefile.PL && make && make install Or via CPAN: cpan App::dategrep You can also install one of the two prebuild versions, which already include all or some of dategrep's dependencies. Which to choose mainly depends on how hard it is for you to install Date::Manip. The small version is just 22.3KB big and includes all libraries except Date::Manip. The big one packs everything in a nice, neat package for you, but will cost you almost 10MB of disk space. Both are always included in the latest release <https://github.com/mdom/dategrep/releases/latest>. So, to install the big version you could just type: wget -O /usr/local/bin/dategrep https://github.com/mdom/dategrep/releases/download/v0.58/dategrep-standalone-big chmod +x /usr/local/bin/dategrep And for the small one (with the apt-get for Debian): apt-get install libdate-manip-perl wget -O /usr/local/bin/dategrep https://github.com/mdom/dategrep/releases/download/v0.58/dategrep-standalone-small chmod +x /usr/local/bin/dategrep
0
ответ дан 18 July 2018 в 06:16

Регулярные выражения делают эту проблему простой. Первая версия выводит даты на или после 2017-9-01.

grep -E "2017-([9]|[0-1][0-9])" file > output_file

Этот второй пример дополнительно фильтрует выход для исключения дат до 2017-9-15. Но только если день месяца равен нулю.

grep -E "2017-([9]|[0-1][0-9])-([0-9]|[0-9][0-9])" file | grep -Ev "2017-9-(0[0-9]|[0-1][0-5])" > output_file

Каждая пара квадратных скобок представляет собой одну цифру. Символ | означает или в регулярном выражении. См. Bash Guide for Beginners Chapter 4. Регулярные выражения для более подробной информации.

1
ответ дан 24 July 2018 в 18:34

Вы можете использовать dategrep. Из perldoc /usr/local/bin/dategrep:

NAME dategrep - print lines matching a date range SYNOPSIS dategrep --start "12:00" --end "12:15" --format "%b %d %H:%M:%S" syslog dategrep --end "12:15" --format "%b %d %H:%M:%S" syslog dategrep --last-minutes 5 --format "%b %d %H:%M:%S" syslog dategrep --last-minutes 5 --format rsyslog syslog cat syslog | dategrep --end "12:15" DESCRIPTION Do you even remember how often in your life you needed to find lines in a log file falling in a date range? And how often you build brittle regexs in grep to match entries spanning over a hour change? dategrep hopes to solve this problem once and for all.

...

INSTALLATION It is possible to install this script via perl normal install routines. perl Makefile.PL && make && make install Or via CPAN: cpan App::dategrep You can also install one of the two prebuild versions, which already include all or some of dategrep's dependencies. Which to choose mainly depends on how hard it is for you to install Date::Manip. The small version is just 22.3KB big and includes all libraries except Date::Manip. The big one packs everything in a nice, neat package for you, but will cost you almost 10MB of disk space. Both are always included in the latest release <https://github.com/mdom/dategrep/releases/latest>. So, to install the big version you could just type: wget -O /usr/local/bin/dategrep https://github.com/mdom/dategrep/releases/download/v0.58/dategrep-standalone-big chmod +x /usr/local/bin/dategrep And for the small one (with the apt-get for Debian): apt-get install libdate-manip-perl wget -O /usr/local/bin/dategrep https://github.com/mdom/dategrep/releases/download/v0.58/dategrep-standalone-small chmod +x /usr/local/bin/dategrep
0
ответ дан 24 July 2018 в 18:34
  • 1
    Это выглядит хорошо, но мой ноутбук просто разбился, так что я буду иметь, чтобы проверить его в немного! – atltt73 25 September 2017 в 04:26

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

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