Posts

Showing posts from September 24, 2018

Sed range problem if the last pattern is not met

Image
Clash Royale CLAN TAG #URR8PPP up vote 0 down vote favorite I am doing a range search with sed. I want to parse the log data from the date and time 2016-09-29 01:00 to 2016-09-29 01:30 . That is why I have been using the following command, $ sed -n '/2016-09-29 01:/,/2016-09-29 01:30:.*$/p' But problem is if 1:30 is not available in log then it returns all the logs to the end. So how can work with this so that if 1:30 doesn't exist it will go to the just next record not till end. Things to consider: Logs contains stack trace so lines contain stack trace doesn't start with the date. sed regular-expression date share | improve this question edited Aug 29 at 11:23 asked Aug 29 at 11:03 muhammad 499 5 14 add a comment  |  up vote 0 down vote favorite I am doing a range search with sed. I want to parse the log data from the date and time 2016-09-29 01:00 to 2016-09-29 01:30 . That is why I h...

cmdline Unix Permissions bits calculator

Image
Clash Royale CLAN TAG #URR8PPP up vote 1 down vote favorite I'd like to convert the Unix Permissions bits from octal to symbolic mode and viceversa. eg.: $ mode-encode 'ugo+rwx' 0000 $ mode-decode 0000 ugo+rwx I know there are online permission bits calculators and chmod supports passing the bits in both ways, but i'd like a bash code snippet i can use with commands that does not support the symbolic mode. EDIT: i'd like to get the permission bits, not the umask! permissions umask share | improve this question edited Aug 30 at 14:30 asked Aug 29 at 11:20 eadmaster 424 3 7 20 Note that for some values of the symbolic forms, the result will depend on the current umask. like for umask +r , or umask g=u (that one not supported by all implementation even though it's POSIX) – Stéphane Chazelas Aug 29 at 12:39 ugo+rwx gives 0000 by the way, not 0777 –Â...