Grabing the username


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grabing the username
# 1  
Old 03-20-2007
Grabing the username

Hi,
Is there a way to grab the username who is running the shell script. I am trying to do is:

$ who am i
Peterd123 pts/5 Mar 20 09:30 (H0021563.xyz.com)

Is there a way to display only the user name above, which is"Peterd123".

Thanks
Raj
rkumar28
# 2  
Old 03-20-2007
Code:
echo ${USER}
who am i | nawk '{print $1}'

# 3  
Old 03-20-2007
Thanks a bunch....it worked for me...
rkumar28
# 4  
Old 03-21-2007
Quote:
Originally Posted by vgersh99
Code:
echo ${USER}
who am i | nawk '{print $1}'

i would go for just,

Code:
whoami

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Why does "ps -[u|U] username" not list processes when username is numeric?

Greetings, The title pretty much says it all. I've snooped everywhere and can't find anything on this. Since our organization went to numeric usernames, using the u|U option for ps returns no processes. Example passwd entry: 320074:DjZAJKXun8HBs:10129:6006:Joe Y:/cadhome/analysis/jy:/bin/bash... (4 Replies)
Discussion started by: crimso
4 Replies

2. Shell Programming and Scripting

Grabing the same timestamp from files that are ZIPPED

Hi, I am zipping more than 20 files that has same timestamp in all of them. I need to create the zip file with the same timestamp as in the files that are zipped. So I have files: Dummytest_20140601W110515_file1.txt Dummytest_20140601W110515_file2.txt ....... .......... (5 Replies)
Discussion started by: Saanvi1
5 Replies

3. Post Here to Contact Site Administrators and Moderators

How to change my username?

Moderators, I want to change my username. I tried but unable to find a way to do that. Can you please assist? Thanks & Regards Abedi (1 Reply)
Discussion started by: katherine2008
1 Replies

4. Post Here to Contact Site Administrators and Moderators

username

Is it possible to change my username in this site or is thre a way to delete my account and then create a new one with a diffrent user name (2 Replies)
Discussion started by: floresr
2 Replies

5. AIX

Cannot delete a username

Hi experts! While I am deleting a username via smitty or by command line with userdel or rmuser y get the following error: Error committing changes to "luke" : Value is invalid. Also when adding a user I get the same error, do you know experts how to solve this issue? I'm using AIX 5.3... (5 Replies)
Discussion started by: agasamapetilon
5 Replies

6. Post Here to Contact Site Administrators and Moderators

Username change

Hello Moderator, My login name is govindts. I wanted to rename this login id to shrinika Would you be able to do this? Thanks (1 Reply)
Discussion started by: govindts
1 Replies

7. Solaris

Using all numeric for username

Hello, We have a Solaris 9 machine and recently our client want to create username based on staff numbers (all numeric). Is there any limitation in Solaris regarding creating username with numeric values (eg: 13598029)? Thanks & Regards Aryawarman Mahzar (5 Replies)
Discussion started by: aryamahzar
5 Replies

8. Shell Programming and Scripting

Grabing Date from filename and adding to the end of each line in the file.

Hi, I have 24 .dat files something like below. The file name starts with “abc” followed by two digit month and two digit year. Is there a way to grab the month and year from each filename and append it to the end of each line. Once this is done I want to combine all the files into file... (1 Reply)
Discussion started by: rkumar28
1 Replies

9. Shell Programming and Scripting

Get username in script

how would i go about getting the username of the person currently logged in, and then using the username in a shell script? i've tried variations of user=whoami , 'whoami' , $whoami , and none of the above work :( lol I'd like to get the username to then mount a network share such that the... (9 Replies)
Discussion started by: willc0de4food
9 Replies

10. Shell Programming and Scripting

Grabing a file from a directory

Hi guys: I need to grab a particular file(s) from a directory. the file name is abc.xyz.2006020101200 I need to grab it based on the bold numbers. The bolded numbers are the date and such files are created everyday. My initial script was to grab the listing of that directory and then cut... (1 Reply)
Discussion started by: geomonap
1 Replies
Login or Register to Ask a Question