joereynolds / what-to-code

Ideas for things to program
MIT License
1.44k stars 63 forks source link

Do the 'file extension' thing #10

Closed BenWiederhake closed 7 years ago

BenWiederhake commented 7 years ago

Technicalities:

Btw, there's a command-line tool called pwgen, so if you were trying to generate a password or something, just do:

$ pwgen -s 20 1
qYzjaQDuWF7f7PssX1fT
joereynolds commented 7 years ago

Hey!

I'm not looking to merge solutions in (The point of the repo is to give people stuff to do) but I'd be happy to link to your repo that contained the solution instead :+1:

Also there's a slight misunderstanding in your solution. From the looks of yours, you're getting a list of all extensions in the current directory whereas the program I had in mind was more atomic in operation.

i.e.

extension some-file.php returns php

It only works on a single file at a time

alexyorke commented 7 years ago

You can use -print0 on the find command to make the paths delimited by a null char (since a filename cannot have a null char in it) which might help resolve the first issue.

BenWiederhake commented 7 years ago

… which destroys greppability, at first, because I didn't know that grep, too, has a -z option that, according to the man page, DoesTheRightThing™.

Anyway, I'm not going to write a script for this because it WorksForMe, so I'll close this PR.