![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
i was trying to work on program to look for users never log on sever.. using awk
with awk is working last| awk '{print $1}' |sort -u > /tmp/users1$$ cat /etc/passwd | awk -F: '{print $1}' |sort -u > /tmp/users2$$ comm -13 /tmp/users[12]$$ rm -f /tmp/users[12]$$ with cut it is not working last| cut -c1-10 |sort -u > /tmp/users1$$ cat /etc/passwd |cut -d':' -f1 | sort -u > /tmp/users2$$ comm -13 /tmp/users[12]$$ rm -f /tmp/users[12]$$ i have another idea by using for loop and count number users repeated. if anyone has better idea to solve this problem please help. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
It isn't working because with cut, you are cutting the first 10 columns. This causes spaces to be padded to the actual usernames in the /tmp/users1$$ file.
Use this instead: last| cut -d" " -f1 |sort -u > /tmp/users1$$ |
|
#3
|
|||
|
|||
|
thanks
it worked ..thanks
but is there any other way by not using comm and diff to compare 2 files .. |
|
#4
|
|||
|
|||
|
I love one-line commands.
Code:
(last | awk '{print$1}'; awk -F: '{print$1}' /etc/passwd) | sort | uniq -u
|
|||
| Google The UNIX and Linux Forums |