Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
user:yeti:opkg-list-user-installed-packages [2018/01/15 20:13] – [2017-01-14] yetiuser:yeti:opkg-list-user-installed-packages [2018/02/03 01:06] – [2018-01-16] yeti
Line 5: Line 5:
 See [[https://unix.stackexchange.com/questions/157097/how-to-know-disk-space-occupied-by-packages-in-openwrt]]. See [[https://unix.stackexchange.com/questions/157097/how-to-know-disk-space-occupied-by-packages-in-openwrt]].
  
-==== 2017-01-14 ====+==== 2018-01-14 ====
  
-<file awk opkg-list-user-installed-packages-sorted-by-size-20170114>+<file awk opkg-list-user-installed-packages-sorted-by-size-20180114>
 #!/usr/bin/awk -f #!/usr/bin/awk -f
 BEGIN { BEGIN {
Line 31: Line 31:
 :!: This originally was created as 1-liner and now just has been unfolded. :!: This originally was created as 1-liner and now just has been unfolded.
  
-==== 2017-01-15 ====+==== 2018-01-15 ====
  
-<file awk opkg-list-user-installed-packages-sorted-by-size-20170115>+<file awk opkg-list-user-installed-packages-sorted-by-size-20180115>
 #!/usr/bin/awk -f #!/usr/bin/awk -f
 BEGIN { BEGIN {
-        D="cd /overlay/upper/usr/lib/opkg/info&&" + D="cd /overlay/upper/usr/lib/opkg/info&&" 
-        C=D"ls *.list" + C=D"ls *.list" 
-        S="sort -n" + S="sort -n" 
-        while(C|getline>0) { + while(C|getline>0) { 
-                P=substr(F=$1,1,length($1)-5) + P=substr(F=$1,1,length($1)-5) 
-                J=D"du -sk $(cat "F")" + J=D"du -sk $(cat "F")" 
-                s=0 + s=0 
-                while(J|getline>0) s+=$1 + while(J|getline>0) s+=$1 
-                close(J) + close(J) 
-                t+=s + t+=s 
-                print s"\t"P|S + print s"\t"P|S 
-        +
-        close(S) + close(S) 
-        print t"\t---TOTAL---"+ print t"\t---TOTAL---"
 } }
 </file> </file>
  
-Moved summing ''t'' (total) to outside the loop.+:!: Moved summing ''t'' (total) to outside the loop
 + 
 +:?: Should the size of the files in ''/overlay/upper/usr/lib/opkg/info/packagename.*'' which describe the package be counted too? Can-o-worms? 
 + 
 +==== 2018-01-16 ==== 
 + 
 +:?: Why ''du -k''? What was the mysterious reason why it makes sense despite being ''du'''s default? 
 + 
 +:?: Why ''du -s''? 
 + 
 +:!: Have a look: //(the example was run on Debian)// 
 +<code> 
 +$ du logs 
 +8       logs/refs/heads 
 +8       logs/refs/remotes/origin 
 +12      logs/refs/remotes 
 +24      logs/refs 
 +32      logs 
 +</code> 
 +The script only needs the summary of directories: 
 +<code> 
 +$ du -s logs 
 +32      logs 
 +</code> 
 +If called with files and directories, files are shown like without ''-s'' and directories are totalled: 
 +<code> 
 +$ ls -ld description logs 
 +-rw-r--r-- 1 yeti yeti   73 Mai 15  2017 description 
 +drwxr-xr-x 3 yeti yeti 4096 Mai 15  2017 logs 
 +$ du -s description logs 
 +4       description 
 +32      logs 
 +</code> 
 +As long as this script shall show no intermediate results, letting ''du'' sum the directories' sizes fits.
  • Last modified: 2019/09/07 19:18
  • by yeti