Live data from Hacker News

Ask HN: Can I see your cheatsheet?

news.ycombinator.com

41–50 of 173 posts

Re: Ask HN: Can I see your cheatsheet?

#41

Earlier quoted context omitted.

same here - my cheatsheet is `history | grep`

I'm curious why history | grep and not ctrl-R?

Probably because ctrl-R doesn't present you a list in most shells. Maybe you want to scan the list visually and look at neighboring commands. ctrl-R doesn't really take advantage of human vision by showing all results next to each other.

Re: Ask HN: Can I see your cheatsheet?

#43

  - Find all files modified in the last 90 minutes  
    find . -type f -mmin -90  
  - Find all files and do something to each one
    find . -type f -mmin -90 | xargs ls -l  
  - Find all files modified before 2 days ago  
    find . -type f -mtime +2  
  - Removing files older than 7 days  
    find . -type f -mtime +7 -name '*.gz' -exec rm {} \;  
  - Find all files modified after last 2 days  
    find . -type f -mtime -2  
  - Find all files modified at the last 2 day mark  
    find . -type f -mtime 2

Re: Ask HN: Can I see your cheatsheet?

#44
post #41

Earlier quoted context omitted.

I'm curious why history | grep and not ctrl-R?

Probably because ctrl-R doesn't present you a list in most shells. Maybe you want to scan the list visually and look at neighboring commands. ctrl-R doesn't really take advantage of human vision by showing all results next to each other.

For me that’s it indeed; grep, sometimes with -A -B is much faster in general for me because it might be similar commands which now will appear next to eachother.

Re: Ask HN: Can I see your cheatsheet?

#45
I feel almost embarassed for sharing some of these, but I either remember things the first time I'm exposed to them or am forever doomed to have to look them up.

    ln -s /the/target the_link (can never remember order)

    for f in *.mp4; do mv "$f" "$(echo "$f" | sed s/S1E/S01E/)"; done

    tar -theuniverse (insert xkcd here)

    grep -E 'foo|bar' file (can never remember the flag for regex)

Re: Ask HN: Can I see your cheatsheet?

#46
post #43

- Find all files modified in the last 90 minutes find . -type f -mmin -90 - Find all files and do something to each one find . -type f -mmin -90 | xargs ls -l - Find all files modified before 2 days ago find . -type f -mtime +2 - Removing files older than 7 days find . -type f -mtime +7 -name '*.gz' -exec rm {} \; - Find all files modified after last 2 days find . -type f -mtime -2 - Find all files modified at the la…

There needs to be a new version of find with a more intuitive UI. (I suspect it exists, but I can't remember the name right now)

Re: Ask HN: Can I see your cheatsheet?

#49

    - List dirs and file count, to find dir with high file count.
      for i in /home/*; do echo $i; find $i | wc -l; done
      for i in /*; do echo $i; find $i | wc -l; done
    - Report space usage of the top level subdirectories.
      du -h --max-depth=2
    - Report space summary only, no directory output.
      du -s -h
    - Find out which device a directory is in.
      df /tmp
      df /home
    - Print of tree of directories
      tree .
    - Disk
      fdisk -l,  list disk partitions
      lsblk,  show a tree of disks, partitions, and lvm volumes
      lsblk -d,  show physical devices
      lsblk -io KNAME,TYPE,SIZE,MODEL,  name/type/size/model
Post reply on HN