Linux system awk to implement Ls-l output file permissions of the digital & build the enhanced version of the LS command

Source: Internet
Author: User
Tags chmod http request syslog file permissions
 


Ls-l | awk ' {k=0;s=0;for (i=0;i<=8;i++) {k+= (substr ($1,i+2,1) ~/[rwxst]/) *2^ (8-i))}j=4;for (i=4;i<=10;i+=3) {s+= (  substr ($1,i,1) ~/[stst]/) *j) j/=2}if (k) {printf ("%0o%0o", S,k)}print} ' total dosage 94372 0755-rwxr-xr-x 1 www. 8597776 August 29   13:22 goproxy_arm 0755-rwxr-xr-x 1 www www 10592880 August 13:29 goproxy_arm64 0644-rw-r--r--1 www www 129 August 16:39 goproxy.bat 0755-rwxr-xr-x 1 www. 8647968 August 13:21 goproxy_darwin_386 0755-rwxr-xr-x 1 www www 10 731424 August 13:21 goproxy_darwin_amd64 0755-rwxr-xr-x 1 www www 8588416 August 13:21 goproxy_freebsd_386 0755-rwxr- Xr-x 1 www www 10696016 August 13:21 goproxy_freebsd_amd64 0755-rwxr-xr-x 1 www www 8631208 August 13:20 goproxy_lin ux_386 0755-rwxr-xr-x 1 www www 10736192 August 13:21 goproxy_linux_amd64 0755-rwxr-xr-x 1 www www 8665088 August 29 1  3:21 goproxy_windows_386.exe 0755-rwxr-xr-x 1 www www 10696704 August 13:22 goproxy_windows_amd64.exe 0644-rw-r--r--1 Root root 18311 August 31 08:09 routes.list.gz 0644-rw-r--r--1 www www. 1536 August 13:49 RunHiddenConsole.exe 




At the same time, the site also made a strengthened version of the LS command

# # One-click upgrade enhanced ls command Wget-cq http://www.dwhd.org/script/lsmod-O/bin/lsmod && chmod + x / bin / lsmod && Echo 'A Lias ls = "/ bin / lsmod "'>> ~ / .BASHRC &&. ~ / .BASHRC ##### #If it is a Debian system, run the following one-click wget-cq http://www.dwhd.org/script/lsmod-O / bin / lshmod && chmod + x / bin / Lshmod && Echo 'Alias ls =' / bin / lshmod '>> ~ / .bashrc &&. ~ / .bashrc




[root@vps197121 ~]# wget http://www.dwhd.org/script/lsmod-O/bin/lsmod && chmod +x/bin/lsmod && Echo ' al IAS ls= "/bin/lsmod" ' >> ~/.BASHRC &&. ~/.BASHRC--2015-09-08 21:25:13--http://www.dwhd.org/script/lsmod resolving www.dwhd.org ... 133.130.100.22, 2400:8500:1301:737:a133:130:100:220 connecting to www.dwhd.org|133.130.100.22|:80 ... Connected. HTTP request sent, awaiting response ... OK length:783 [Application/octet-stream] saving to: "/bin/lsmod" 100%[=========================================== ====================================&GT] 783--.-k/s in 0s 2015-09-08 21:25:14 (75.5 MB/s)-"/bin/lsmod "Saved [783/783] [root@vps197121 ~]# ls-l 0200 Total 0644-rw-r--r--1 root root 3886 Sep 7 20:08 bench.sh 0644- rw-r--r--1 root 4398 Aug 22:26 init.sh 0644-rw-r--r--. 1 root 10281 Dec 1 2014 install.log 0644-rw-r--r--. 1 root 3317 Dec 1 2014 install.log.syslog [root@vps197121 ~]# ls-la 0200 Total 10550 Dr-xr-x---. 5 root 4096 Sep 8 19:00. 0555 Dr-xr-xr-x. Root root 4096 Aug 31 02:47. 0600-RW-------. 1 root 3376 Sep 8 18:37. Bash_history 0644-rw-r--r--. 1 root 2009 Bash_logout 0644-rw-r--r--. 1 root 176 May 2009 Bash_profile 0644-rw-r--r--1 root Sep 8 21:25 BASHRC 1 Root root 3886 Sep 7 20:08 bench.sh 0644-rw-r--r--. 1 root Sep cshrc 0644-rw-r--r--1 root root 4398 Aug 22:26 init.sh 0644-rw-r--r--. 1 root 10281 Dec 1 2014 install.log 0644-rw-r--r--. 1 root 3317 Dec 1 2014 install.log.syslog 0755 drwxr-xr-x 5 root 4096 Aug-05:24. Ipython 0740 drwxr---- -3 root root 4096 Aug 05:19. PKI 0644-rw-r--r--1 501 501 4149 June 9 11:40. SCREENRC 0700 drwx------. 2 root 4096 Sep 7 21:28. SSH 0644-rw-r--r--. 1 root 129 Dec 3 TCSHRC 0600-rw-------1 root 4328 Sep 8 17:39 viminfor--r--1 501 501 4546 June 11:33. vimrc 0600-rw-------1 root root 126 Sep 8 18:43. xauthority [root@vps197121 ~]# ls/etc/fstab/etc/fstab [root@vps197121 ~]# ls/etc/fstab-l 0644-rw-r--r--. 1 root 585 Aug 02:45/etc/fstab [root@vps197121 ~]#




The difference between the original and the enhanced version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.