LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Converting sLoPPy cASE to Pretty Case with tr (https://www.linuxquestions.org/questions/programming-9/converting-sloppy-case-to-pretty-case-with-tr-312989/)

lowpro2k3 04-13-2005 07:23 PM

Converting sLoPPy cASE to Pretty Case with tr
 
I need a quick one-liner for an assignment to convert strings of any type (including uGLY sTuFF lIKE thiS) into strings like these (Doesnt This Look A Lot Nicer?)

I also have to convert AnY CasE to UPPER CASE, but that one was easy (echo str | tr [:lower:] [:upper:]) but I can't figure out how to get the first character to convert and not the whole string. I could do some substringing, but dont really want to if I dont have to (btw this is in bash...)

Tinkster 04-13-2005 07:47 PM

Since it's an assignment question I suggest you research
the possibilities using google and experiments ...

Asking Homework questions is against the RULES


Cheers,
Tink

lowpro2k3 04-13-2005 08:05 PM

Its a huge assignment, I'm asking for literally 1/3 of a one-liner. I have my textbook out and I've searched google like 19 times. Its pretty trivial for anyone who knows how to do it. I'm just not a fan of wasting insane amounts of time on a something trivial like this while I have other assignments in assembly, c++ and web programming. I fully understand the reason for the rules, but if I didnt mutter the words 'for my assignment' nobody would have known and I would have got the answer. At least i'm being honest. If it was for a project at work would that be OK? Please explain the difference. I understand "its for my own good" and all that, but I need to finish MANY assignments in the next 2 days so I can GO HOME and see my family instead of wasting time fidgeting with tr in Linux.

Code:

echo "str" | tr [:upper:] [:lower:] | MY QUESTION
At least I didnt post my entire assignment and ask you guys to write the code like 90% of the school questions on this forum. I'm stressed out, its exam time, I desperately want to finish my multiple remaining assignments so I can drive home this weekend and see my family and friends, I AM on google with my textbook in front of me and I caught a glimmer of hope opening this thread thinking someone answered my question. I dont mean to sound like an a-hole but I'm very stressed and I can barely think straight enough. This question about my assignment is less than a line out of hundreds, spanning 2 (g)awk scripts and a large bash script. Not the biggest program ever, but believe me I've done my fair share of my own code with the textbook and google.

Thanks for understanding.

BTW I still haven't got it yet and would still appreciate an answer. My head is spinning from lack of cigarettes (quit last week) and too much programming. Please understand. Thanks.

Tinkster 04-13-2005 08:08 PM

C'mon kiddo, don't get lippy with me. You've signed up and
agreed to the rules, and that's the end of the discussion.


Cheers,
Tink

lowpro2k3 04-13-2005 08:13 PM

fine


All times are GMT -5. The time now is 12:14 AM.