Live data from Hacker News

Ask HN: Can I see your cheatsheet?

news.ycombinator.com

91–100 of 173 posts

Re: Ask HN: Can I see your cheatsheet?

#91
post #60

I use my ebooks for reference: * GNU grep and ripgrep ( https://learnbyexample.github.io/learn_gnugrep_ripgrep/ ) * GNU sed ( https://learnbyexample.github.io/learn_gnused/ ) * GNU awk ( https://learnbyexample.github.io/learn_gnuawk/ ) * Ruby one-liners cookbook ( https://learnbyexample.github.io/learn_ruby_oneliners/ ) * Perl one-liners cookbook ( https://learnbyexample.github.io/learn_perl_oneliners/ ) * Command li…

I consider myself pretty experienced at shell-fu and capable of doing most things I set out to achieve in either bash scripts or fearless one-liners. However, my awk is rudimentary at best, I think mostly because it's such an unforgiving environment to experiment in.

These books you've written are great for a bit of first principles insight and then quickly building up to functional usage. I will have no hesitation in referring colleagues to them!

Do you have a patreon or something similar? Do you accept pull requests for collaboration?

Thanks for creating such great free material!

Re: Ask HN: Can I see your cheatsheet?

#93
post #86

Set a huuuuuuuge shell history https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf... then fzf ctrl+r bindings mean you can recall anything right where you need it. If you’re going to do this then have an escape hatch for commands you don’t want memorised https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf...

Your file just reminded me I have "broot" installed.. Its sad how I install all those things, forget about them the next day and cd/ls/vi like a caveman. The problem is much deeper than you think, OP...

Yep, this is my real problem. Install something that looks cool, then get wrapped up in the day-to-day and never make it muscle memory.

Sounds like I should be focusing on "one new workflow thing a week" and make it a daily habit to practice, or something.

Re: Ask HN: Can I see your cheatsheet?

#94
post #87

Earlier quoted context omitted.

With zsh you don't need to use find, fd, or any other external tool. zsh's built-in globbing features can be used instead. - Find all files modified in the last 90 minutes print -l **/*(mm-90) - Find all files and do something to each one print -l **/*(mm-90) | xargs ls -l - Find all files modified before 2 days ago print -l **/*(m+2) - Removing files older than 7 days zargs -- **/*(m+7) -- rm - Find all files modifi…

The zsh rm command doesn't with too many (say, 100 000) files, execve() fails with: Argument list too long. This works and it is relatively fast (runs rm in big batches): find ... | xargs -d '\n' rm --

For you can skip xargs for that and just add the -delete argument to find, for readability and profit(!?)

Re: Ask HN: Can I see your cheatsheet?

#95
post #78
post #75

Earlier quoted context omitted.

I‘ve been doing this ever since I migrated from Windows to Mac in 2015. My bash history has over 40k lines, datestamped. I can recall any command I have typed in my terminal in the past seven years. Extremely helpful whenever I need to repeat anything in the terminal. # Edit I sometimes add comments to commands via `# This‘ll do this and that` so that I can find the command by those keywords in the bash history.

This. I've been doing this for a couple of years now, I'm really used to it. I've been "traveling" with my history that is over 70k lines. My dot alias file has only 3 aliases (c=clear, q=exit, gti=git). Hope there's a project out there that helps parse, rank, or do something with a file like this. There must be interesting information.

[deleted]

Re: Ask HN: Can I see your cheatsheet?

#96
Delete empty files / empty directories

find . -type f -empty -print -delete

find . -type d -empty -print -delete

Move photos/videos to folder, based on their creation date

exiftool -d /home/user/Photos/%Y-%m-%d "-directory(or leave the extension out, and all files with EXIF data will be included)

Re: Ask HN: Can I see your cheatsheet?

#97
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…

Please use `find -print0 | xargs -0` (or -exec) when running commands on files, otherwise xargs will mangle filenames in some cases.

Re: Ask HN: Can I see your cheatsheet?

#98
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…

Depending on how you name your files, you want to add -print0 to your find and -o to your xargs. If you have spaces in your file names you want that to carry over in your xargs.

Secondly, you may want to add -n 200 to your xargs so if you have very, very many files bash doesn't complain.

So:

Find all files and do something to each one

    find . -type f -mmin -90 -print0 | xargs -0 -n 1024 ls -l

Re: Ask HN: Can I see your cheatsheet?

#99
post #60

I use my ebooks for reference: * GNU grep and ripgrep ( https://learnbyexample.github.io/learn_gnugrep_ripgrep/ ) * GNU sed ( https://learnbyexample.github.io/learn_gnused/ ) * GNU awk ( https://learnbyexample.github.io/learn_gnuawk/ ) * Ruby one-liners cookbook ( https://learnbyexample.github.io/learn_ruby_oneliners/ ) * Perl one-liners cookbook ( https://learnbyexample.github.io/learn_perl_oneliners/ ) * Command li…

I consider myself pretty experienced at shell-fu and capable of doing most things I set out to achieve in either bash scripts or fearless one-liners. However, my awk is rudimentary at best, I think mostly because it's such an unforgiving environment to experiment in. These books you've written are great for a bit of first principles insight and then quickly building up to functional usage. I will have no hesitation i…

Thanks a lot for the feedback :)

Curious about what kind of issues you had with `awk`. Perhaps https://awk.js.org/ could help?

>Do you have a patreon or something similar?

I pay my bills by selling PDF/EPUB versions of these books. Purchase links are mentioned in the 'Buy' page. You can also visit https://learnbyexample.gumroad.com/ or https://leanpub.com/u/learnbyexample

>Do you accept pull requests for collaboration?

Not currently. You can file issues on GitHub (links are mentioned in the preface chapter) for typos/bugs/suggestions/etc.

Markdown source for these books are also available on GitHub.

Re: Ask HN: Can I see your cheatsheet?

#100

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)

I started remembering the order for ln when I think of it as a copy which just happens to be special. cp SRC DEST is intuitive to me so I just hang ln off that.

I did that as well, also running cp with the -s argument will create a symlink
Post reply on HN