ls 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/rc
  2. # flags common to GNU and BSD ls
  3. # -A all except . and ..
  4. # -C force mc
  5. # -F usual
  6. # -H follow symlinks
  7. # -L follow symlinks
  8. # -R recursive list
  9. # -U unsorted (gnu)
  10. #
  11. # -a include .files
  12. # -c show ctime
  13. # -d dirs
  14. # -f no sorting
  15. # -l long
  16. # -p put slash after dir (-F)
  17. # -r reverse
  18. # -s sizes
  19. # -t time sort
  20. # -u utime
  21. # -1 single-column
  22. flagfmt='A,C,F,H,L,R,U,a,c,d,f,l,p,r,s,t,u,1'
  23. args='[file ...]'
  24. if(! ifs=() eval `{aux/getflags $*}){
  25. aux/usage
  26. exit usage
  27. }
  28. fn fixlong {
  29. echo total 1000
  30. /$cputype/bin/sed 's/^(.).(.........) . [0-9]+ /\1\2 1 /'
  31. }
  32. post=cat
  33. all=()
  34. # ignore -A
  35. if(~ $flagC 1) post=mc
  36. if(~ $flagF 1) all=($all -F)
  37. # ignore -H, -L
  38. # save -R for later
  39. if(~ $flagU 1) all=($all -n)
  40. # ignore -a, -c
  41. if(~ $flagd 1) all=($all -d)
  42. if(~ $flagf 1) all=($all -n)
  43. if(~ $flagl 1) { all=($all -l); post=fixlong }
  44. if(~ $flagp 1) all=($all -F)
  45. if(~ $flagr 1) all=($all -r)
  46. if(~ $flags 1) all=($all -s)
  47. if(~ $flagt 1) all=($all -t)
  48. if(~ $flagu 1) all=($all -u)
  49. # ignore -1
  50. /$objtype/bin/ls $all $* | $post