bash_funcs.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # These are bash functions that are getting to large to fit in .bashrc
  3. #
  4. source $HOME/lib/bash/bashutils.sh # error,warning,...
  5. function csvls()
  6. (
  7. # ls as csv
  8. # https://stackoverflow.com/questions/14573262/convert-ls-output-into-csv
  9. find . -ls | awk '{printf( "%s,%s,%s,%s,%s,%s,%s,%s %s %s,%s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11 )}'
  10. )
  11. # Grep out common "junk" files and directories. Ubuntu/Linux specific.
  12. alias nojunk="egrep -vi \.snap\|\.config\|\.cache\|.git\|.local"
  13. # Find recently modified files or directories
  14. # The intent is to find "things I've been working on recently"
  15. function recentf ()
  16. # find recently modified files
  17. #
  18. # Usage: recentf [DIR [AGE]]
  19. #
  20. # Defaults: DIR=., AGE=3
  21. {
  22. # find recently modified files
  23. #
  24. # Usage: recentf [directory [days]]
  25. find ${1:-.} -mtime -${2:-3} -print | \
  26. nojunk | \
  27. sort | \
  28. uniq
  29. }
  30. function recentd ()
  31. {
  32. # find directories with recently modified files
  33. #
  34. # Usage: recentd [directory [days]]
  35. find ${1:-.} -mtime -${2:-3} -print | \
  36. nojunk | \
  37. sed 's#/[^/]*$##' | \
  38. sort | \
  39. uniq
  40. }