Показаны сообщения с ярлыком bash. Показать все сообщения
Показаны сообщения с ярлыком bash. Показать все сообщения

вторник, 19 марта 2013 г.

grep support for \d

A long time ago, when every PC had own OS, it was easy to remember, which RegEx are from POSIX standart, and which appeared only in Perl-style. Now it’s almost forgotten, and C# regexp classes don’t support POSIX character classes (like [:digit:]).

That’s why the debugging of a simple bash script is so difficult. grep is older then a lot of his users, he remembers all of these times and needs -P for Perl mode and ‘\d’ for digits support.

That’s how

ls | grep -e "[0-9][0-9].[0-9][0-9].md"

becames:

ls | grep -Pe "\d{2}.\d{2}.md"

Git: How to rename a GitHub repo

GitHub allows to rename your repos. I really like this solution.

Install curl if you haven’t and use terminal (or cygwin under windows):

user=MyUserName
pass=MyPassword
newName='{"name": "NewNameForRepo"}'
oldName="MyRepo"
curl -u "$user:$pass" -X PATCH -d "$newName" https://api.github.com/repos/$user/$oldName

четверг, 22 ноября 2012 г.

Kosher PC

Придумался скрипт для ортодоксальных иудеев, которые сидят под *nix-ом и стараются соблюдать котев штей отийот – запрет писать две буквы в Шаббат.

Надо открыть .profile и вписать в самое начало:

if ([ `date +"%w"` -eq 0 ]) then shutdown -h now fi

Теперь Ubuntu тоже будет соблюдать Шаббат и выключаться, если на календаре седьмой день недели.