News for hackers. Stuff that matters.
Re:The X-Y Problem by pathikrit on Thursday January 19, 2023 @04:08PM (#34445635)
Why not respond with both X and Y? e.g. for the last 3 character thing, here would be an appropriate response:

To get the last 3 characters, do `echo ${foo: -3}`. Are you trying to get the file extension though? What if the extension is not 3 characters e.g. `foo.jpeg`? You then want to do `${foo##*.}`

Re:The X-Y Problem by bee_rider on Thursday January 19, 2023 @04:12PM (#34445671)
Some more probing might still be needed for the second solution, how a .tar.gz gets handled might depend on the programmer intent, could be different from a .gz hypothetically.
Re:The X-Y Problem by seba_dos1 on Thursday January 19, 2023 @04:14PM (#34445691)
Because not every answer is as quick and straightforward as your example.
Re:The X-Y Problem by IshKebab on Thursday January 19, 2023 @05:12PM (#34446405)
Yeah this is definitely the best response. Unfortunately most people (especially on Stackoverflow) are not as wise as you and will just downvote your question and say "you shouldn't do that".