{"id":665,"date":"2007-08-17T11:58:21","date_gmt":"2007-08-17T09:58:21","guid":{"rendered":"http:\/\/planetozh.com\/blog\/2007\/08\/what-chmod-symbolic-to-octal-notation-perl-script\/"},"modified":"2007-08-17T11:58:21","modified_gmt":"2007-08-17T09:58:21","slug":"what-chmod-symbolic-to-octal-notation-perl-script","status":"publish","type":"post","link":"https:\/\/planetozh.com\/blog\/2007\/08\/what-chmod-symbolic-to-octal-notation-perl-script\/","title":{"rendered":"What Chmod ? Symbolic to Octal Notation Perl Script"},"content":{"rendered":"<p>Have you ever &quot;<em>ls -l<\/em>&quot; a file or directory, watch its &quot;-r-x&#8211;s-wT&quot; symbolic notation and ask to yourself: &quot;what the hell is that chmod ?&quot;. This was the case for me several times today, so before I spent 1 minute on thinking about the notation, I decided to spent 5 minutes on a quick Perl script. <strong>What Chmod<\/strong> converts those stinky <em>&#8212;xr-s-wT<\/em> into the octal <em>3152<\/em> value.<br \/>\n<!--more--><\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">perl<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"perl\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\">#!\/usr\/bin\/perl<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\">#===========================================================#<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># What Chmod ? Simple Perl utility to convert a symbolic &nbsp; &nbsp;#<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># chmod string (rwxr-x--x) into its octal notation (755) &nbsp; &nbsp;#<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># Ozh - http:\/\/planetozh.com &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\">#===========================================================#<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0000ff\">$arg<\/span> <span style=\"color: #339933\">=<\/span> <span style=\"color: #0000ff\">$ARGV<\/span><span style=\"color: #009900\">&#091;<\/span><span style=\"color: #cc66cc\">0<\/span><span style=\"color: #009900\">&#093;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># no argument or bad argument length<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #339933\">!<\/span><span style=\"color: #0000ff\">$arg<\/span> <span style=\"color: #339933\">||<\/span> <span style=\"color: #000066\">length<\/span> <span style=\"color: #0000ff\">$arg<\/span> <span style=\"color: #339933\">&lt;<\/span> <span style=\"color: #cc66cc\">9<\/span> <span style=\"color: #339933\">||<\/span> <span style=\"color: #000066\">length<\/span> <span style=\"color: #0000ff\">$arg<\/span> <span style=\"color: #339933\">&gt;<\/span><span style=\"color: #cc66cc\">10<\/span> <span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #000066\">print<\/span> <span style=\"color: #ff0000\">&quot;Usage: $0 &lt;pattern&gt;<span style=\"color: #000099;font-weight: bold\">\\n<\/span>&quot;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #000066\">print<\/span> <span style=\"color: #ff0000\">&quot;Example: $0 rwxr-x--x<span style=\"color: #000099;font-weight: bold\">\\n<\/span>&quot;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #000066\">exit<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># remove the filetype bit<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #000066\">length<\/span> <span style=\"color: #0000ff\">$arg<\/span> <span style=\"color: #339933\">&gt;<\/span> <span style=\"color: #cc66cc\">9<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0000ff\">$arg<\/span> <span style=\"color: #339933\">=<\/span> <span style=\"color: #000066\">substr<\/span><span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$arg<\/span><span style=\"color: #339933\">,<\/span><span style=\"color: #cc66cc\">1<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000066\">print<\/span> <span style=\"color: #0000ff\">$arg<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># o: owner, g: group, w:others (world)<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$or<\/span><span style=\"color: #339933\">,<\/span><span style=\"color: #0000ff\">$ow<\/span><span style=\"color: #339933\">,<\/span><span style=\"color: #0000ff\">$ox<\/span><span style=\"color: #339933\">,<\/span><span style=\"color: #0000ff\">$gr<\/span><span style=\"color: #339933\">,<\/span><span style=\"color: #0000ff\">$gw<\/span><span style=\"color: #339933\">,<\/span><span style=\"color: #0000ff\">$gx<\/span><span style=\"color: #339933\">,<\/span><span style=\"color: #0000ff\">$wr<\/span><span style=\"color: #339933\">,<\/span><span style=\"color: #0000ff\">$ww<\/span><span style=\"color: #339933\">,<\/span><span style=\"color: #0000ff\">$wx<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #339933\">=<\/span> <span style=\"color: #000066\">split<\/span><span style=\"color: #009900\">&#040;<\/span><span style=\"color: #339933\">\/\/,<\/span><span style=\"color: #0000ff\">$arg<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0000ff\">$o<\/span><span style=\"color: #339933\">=<\/span><span style=\"color: #cc66cc\">0<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0000ff\">$g<\/span><span style=\"color: #339933\">=<\/span><span style=\"color: #cc66cc\">0<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0000ff\">$w<\/span><span style=\"color: #339933\">=<\/span><span style=\"color: #cc66cc\">0<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># Owner (or User) bit<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$or<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;r&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$o<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">4<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$ow<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;w&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$o<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">2<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$ox<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;x&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$o<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">1<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># Setuid bit<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$ox<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;S&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$s<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">4<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$ox<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;s&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$s<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">4<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #0000ff\">$o<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">1<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># Group bit<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$gr<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;r&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$g<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">4<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$gw<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;w&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$g<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">2<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$gx<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;x&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$g<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">1<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># Setgid bit<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$gx<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;S&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$s<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">2<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$gx<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;s&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$s<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">2<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #0000ff\">$g<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">1<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># Other (or World) bit<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$wr<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;r&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$w<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">4<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$ww<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;w&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$w<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">2<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$wx<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;x&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$w<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">1<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\"># Sticky bit<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$wx<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;T&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$s<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">1<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">$wx<\/span> <span style=\"color: #b1b100\">eq<\/span> <span style=\"color: #ff0000\">&quot;t&quot;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><span style=\"color: #0000ff\">$s<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">1<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #0000ff\">$w<\/span> <span style=\"color: #339933\">+=<\/span> <span style=\"color: #cc66cc\">1<\/span><span style=\"color: #339933\">;<\/span><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000066\">print<\/span> <span style=\"color: #ff0000\">&quot; = $s$o$g$w<span style=\"color: #000099;font-weight: bold\">\\n<\/span>&quot;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000066\">exit<\/span> <span style=\"color: #cc66cc\">1<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Usage :<\/p>\n<div id=\"ig-sh-2\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">code<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"code\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">$ .\/whatchmod rw--w--wT<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">rw--w--wT = 1622<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Have you ever &quot;ls -l&quot; a file or directory, watch its &quot;-r-x&#8211;s-wT&quot; symbolic notation and ask to yourself: &quot;what the hell is that chmod ?&quot;. This was the case for me several times today, so before I spent 1 minute on thinking about the notation, I decided to spent 5 minutes on a quick Perl [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[235,2,3,9],"class_list":["post-665","post","type-post","status-publish","format-standard","hentry","tag-chmod","tag-code","tag-linux","tag-perl"],"_links":{"self":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/comments?post=665"}],"version-history":[{"count":0,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/665\/revisions"}],"wp:attachment":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/media?parent=665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/categories?post=665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/tags?post=665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}