yup...i shud have seen that...thanks...!!
even i tried writing something ,though its not giving me entirely what i want..
cat /etc/group | nawk '
{
TUP = split($0, field, ":");
USERS = split(field[4],user, ",");
if (USERS == 0) printf "%s\t%s\t%s\n", field[1], field[3], "NULL";
for (i = 1; i <= USERS; i++)
printf "%s\t%s\t%s\n", field[1], field[3], user;
}
'
I m just setting NULL wherever userlist if NULL.
Can someone tell me how do i split the row by removing ':' from it into just a row with n columns
lp:!:11:root,lp,printq
into
lp ! 11 root,lp,printq
such that i can just pick column values using 'awk'.
Regards
Abhi
---------- Post updated at 02:25 PM ---------- Previous update was at 02:02 PM ----------
okay...this might be it...
bash-3.00$ D='lp:!:11:root,lp,printq'
bash-3.00$ echo $D |sed 's/:/ /g'
lp ! 11 root,lp,printq
bash-3.00$ echo $D |sed 's/:/ /g'|awk '{print $1}'
lp
bash-3.00$ echo $D |sed 's/:/ /g'|awk '{print $2}'
!
bash-3.00$ echo $D |sed 's/:/ /g'|awk '{print $3}'
11
bash-3.00$ echo $D |sed 's/:/ /g'|awk '{print $4}'
root,lp,printq
Regards
Abhi
---------- Post updated at 02:39 PM ---------- Previous update was at 02:25 PM ----------
now this one is from /etc/passwd file
abhi:!:34971:3418:abhi k, Sys Admin Level 3:/home/users/abhi:/bin/ksh
As we can see,in comments section i have put something against my user id.
using the same code above pasted
bash-3.00$ echo $D|sed 's/:/ /g'|awk '{print $5 $6 $7 $8 $9 $10}'
abhik,SysAdminLevel3
I want "abhi k ,Sys Admin Level 3" to be put in just one column as it is (no space deletion).Rest columns are easy to get.
Any ideas ?
Regards
Abhi
---------- Post updated at 03:48 PM ---------- Previous update was at 02:39 PM ----------
i thought this wud work...but it isn't....anything missing?
bash-3.00$ echo $D|sed 's/:/ /g'|awk -F' ' '{$1=$2=$3=$4="";sub("^ ","");print}'
abhi k, Sys Admin Level 3 /home/users/abhi/ /bin/ksh
i just need "abhi k, Sys Admin Level 3".....
Regards
Abhi
---------- Post updated at 04:12 PM ---------- Previous update was at 03:48 PM ----------
bash-3.00$ echo $D|sed 's/:/ /g'|awk -F' ' '{$1=$2=$3=$4="";sub("^ ","");print}'|cut -d "/" -f1
abhi k, Sys Admin Level 3
i hope i am not sounding crazy here....
Regards
Abhi