Skip to content
October 9, 2015 / doganay

PERMISSION and OWNERSHIP (chmod & chown) GENERATOR SCRIPT

which nawk;if [ $? -ne 0 ];then AWK="awk";else AWK="nawk";fi
uname -a|grep -i linux 1>/dev/null;if [ $? -eq 0 ]; then V_LINUX=1;else V_LINUX=0;fi
ls -ltr | grep -v "^total" | \
$AWK '{
 v_1=substr($1,2,3);
 v_2=substr($1,5,3);
 v_3=substr($1,8,3);

 gsub("-","",v_1);
 gsub("s","xs",v_1);

 gsub("-","",v_2);
 gsub("s","xs",v_2);

 gsub("-","",v_3);
 gsub("s","xs",v_3);
 gsub("T","",v_3);

 printf "chmod u="v_1",g="v_2",o="v_3" "$NF"\n";

 if(index($1,"T")>0&&'$V_LINUX'==1) print "chmod +t " $NF;

 print "chown "$3":"$4" "$NF
}'
Advertisements

One Comment

Leave a Comment
  1. doganay / Oct 19 2015 11:52 am

    Reblogged this on Mustafa DOGANAY's Blog.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: