bash-2.05$ vi file_read.sh
"file_read.sh" 9 lines, 97 characters
#!/bin/ksh
print "Enter the group name"
read gname
varA= grep "$gname::" group
print $varA
This is the scenario: I am trying to get a userid and groupname from user and trying to add the userid to the given group. Please advise how to do this in KSH
bash-2.05$ ./file_read.sh
Enter the group name
staff
./file_read.sh[6]: Print: not found
user
awk: syntax error near line 1
awk: bailing out near line 1
print "Enter the group name"
read group
Print "Enter the user name"
read user
nawk -v u=$user -v g=$group -F: '{if ($1==g) $NF=$NF","u}1' OFS=: /etc/group
I still think you are wise to use the OS command designed for doing this job, it takes into account many other factors including shadow files and the like. By all means put your own front-end on it to prompt for (and validate) the parameters, but stick with the tool designed to get the job done right.