Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Output from who command - quick riddle Post 302494169 by losingit on Saturday 5th of February 2011 11:41:37 PM
Old 02-06-2011
Output from who command - quick riddle

Hi all.

So I have a problem. I have been doing real good figuring this stuff out on my own but Im a newbie and stuck on something that is probably real basic.

I want to get the following output from the who command:
Code:
User    TTY   Date  Time
gd22a12 pts/1 Feb 1 11:34
gd22a13 pts/3 Feb 1 11:55
gd22a14 pts/2 Feb 1 11:33

I do not want the IP addresses that come in the standard who command so I know I would need to cut somehow but Im lost between that and pacing those headers above the top of the file.

So far Ive come up with this.....
Code:
who | cut -c1-7,9-15,23-25,28-34

Problem is my headers are not lined up over the output. What would be the best way to handle this? Just a hint owuld be good and I will research the rest! :-)

Moderator's Comments:
Mod Comment Please use code tags, and a more descriptive subject title next time

Last edited by Scott; 02-06-2011 at 07:24 AM..
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Quick help with the date command...

I'm new to unix, and I was wondering how would you output the following date using the date command? Thank you in advance. November 4,2005 17:04:31 EST Wednesday (1 Reply)
Discussion started by: Newguy4
1 Replies

2. Shell Programming and Scripting

Riddle - solve it if you can

I don't understand this, can anyone explain the evaluation logic used here, and I would really appreciate a general explanation for it. ---------------------- Here's the korn script: -------------------- #! /usr/bin/ksh if ] then echo true else echo false fi if (( 2 > 10 )) then... (1 Reply)
Discussion started by: numstr
1 Replies

3. Shell Programming and Scripting

Quick Question on sed command in shell script

Hello, I have the following line in one of my shell scripts. It works fine when the search string($SERACH_STR) exists in the logfile($ALERTLOG) but if the search string does not exist this line errors out at run time. Is there a way to make this line return 0 if it is not able to find the... (4 Replies)
Discussion started by: luft
4 Replies

4. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

5. Shell Programming and Scripting

Ksh riddle: interpret variable two times?

exam is a ksh script. In command line I enter: exam 3 param_2 param_3 param_4. In exam how can I get the value of the parameter which position is specified by the first argument. Simply doing this DOES NOT work: offset=$1 value=$$offset can you figure out any possible way to interpret a... (5 Replies)
Discussion started by: i27oak
5 Replies

6. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

7. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

8. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies
ID(1)							    BSD General Commands Manual 						     ID(1)

NAME
id -- return user identity SYNOPSIS
id [user] id -G [-n] [user] id -g [-nr] [user] id -p [user] id -u [-nr] [user] DESCRIPTION
The id utility displays the user and group names and numeric IDs, of the calling process, to the standard output. If the real and effective IDs are different, both are displayed, otherwise only the real ID is displayed. If a user (login name or user ID) is specified, the user and group IDs of that user are displayed. In this case, the real and effective IDs are assumed to be the same. The options are as follows: -G Display the different group IDs (effective, real and supplementary) as white-space separated numbers, in no particular order. -g Display the effective group ID as a number. -n Display the name of the user or group ID for the -G, -g and -u options instead of the number. If any of the ID numbers cannot be mapped into names, the number will be displayed as usual. -p Make the output human-readable. If the user name returned by getlogin(2) is different from the login name referenced by the user ID, the name returned by getlogin(2) is displayed, preceded by the keyword ``login''. The user ID as a name is displayed, preceded by the keyword ``uid''. If the effective user ID is different from the real user ID, the real user ID is displayed as a name, preceded by the keyword ``euid''. If the effective group ID is different from the real group ID, the real group ID is displayed as a name, preceded by the keyword ``rgid''. The list of groups to which the user belongs is then displayed as names, preceded by the keyword ``groups''. Each display is on a separate line. -r Display the real ID for the -g and -u options instead of the effective ID. -u Display the effective user ID as a number. The id utility exits 0 on success, and >0 if an error occurs. SEE ALSO
who(1) STANDARDS
The id function is expected to conform to IEEE Std 1003.2 (``POSIX.2''). HISTORY
The historic groups(1) command is equivalent to ``id -Gn [user]''. The historic whoami(1) command is equivalent to ``id -un''. The id command first appeared in 4.4BSD. BSD
May 5, 1994 BSD
All times are GMT -4. The time now is 04:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy