Extract part of $USER in script

I need to be able to say "My name is $USER' when I use echo it work, when I use printf it print more 'my last name@.........'. How can I get just the part before the @ sign. I have to use printf. using UNIX.

------ Post updated at 01:17 PM ------

I used the activation code but I still can't post. Im taking a class and really need help.

First off: as i said in the other thread already, if this is homework or classwork you need to post in the special forum part : Homework & Coursework Questions.

Second: if you have tried code and it doesn't work - post it here, however buggy. How are we supposed to tell you what you did wrong if we can't see what you did?

And, finally: please do post multiple times just because you don't get an immediate answer. We are volunteers here, this is not a paid helpdesk. It is not unusual to wait a day for an answer. If you need immediate, responsible help please pay a professional to work for you.

And this is funny, because actually you are posting here.

I hope this helps.

bakunin

I moved the thread to "UNIX for Beginners Questions & Answers" - and closed it. Please comply to the forum rules that you accepted when you registered: post homework / classwork in the home- and coursework forum respecting the home- and coursework rules.

Nevertheless, a few comments to your post:

  • A shell (and every other) variable has a value / contents that does not change depending on how it is used / evaluated. So $USER will show the same, be it echo ed or printf ed.
  • Urgent ("really need help") posts are deprected in here and don't get increased attention nor are they preferredly answered.
  • Heed what other, longer term members (here: bakunin) are suggesting on how to prepare a post so people ready to answer don't need to guess about what be the real problem.