Question & Answer: Bash, unix…..

Bash, unix

Who utility displays , use one line of utilities connected with pipes

Alice pts/12 Aug 1 21:50 (ip)
Joe pts/13 July 10 1:00 (ip)

Etc….

1. Assume they are separated by tabs, extract name and ip using one line of utilities.

E. G.
Alice (ip)
Joe (ip)

2. Sort list based on month

3. Currently logged on from july

4. Logged on from July, sorted based on login date, then displays top 6 people from list

5. Do 4. Without pipes

Expert Answer

 

$ who | cut -d’ ‘ -f1 | sort | uniq
john
jason
ramesh

$ who
ramesh pts/0 2009-03-28 22:57 (dev-db-server)
jason pts/1 2009-03-28 23:01 (dev-db-server)
john pts/2 2009-03-28 23:04 (dev-db-server)

$ last jason
jason pts/0 dev-db-server Fri Mar 27 22:57 still logged in
jason pts/0 dev-db-server Fri Mar 27 22:09 – 22:54 (00:45)
jason pts/0 dev-db-server Wed Mar 25 19:58 – 22:26 (02:28)
jason pts/1 dev-db-server Mon Mar 16 20:10 – 21:44 (01:33)
jason pts/0 192.168.201.11 Fri Mar 13 08:35 – 16:46 (08:11)
jason pts/1 192.168.201.12 Thu Mar 12 09:03 – 09:19 (00:15)
jason pts/0 dev-db-server Wed Mar 11 20:11 – 20:50 (00:39

Still stressed from student homework?
Get quality assistance from academic writers!