On 7/21/11 4:33 AM, dave jones wrote:
> Hi,
>
> I have a config file below:
>
> $user = 'root'; // This is the username
>
> if $user is found, I want to display root.
> Anyone knows how to programming in C or some other language? thank you.
>
> Regards,
> Dave.
> _______________________________________________
> [email protected] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "[email protected]"
Let us assume you want to read your file, then display each entry for
"$user1" , "$user2" and so on:
grep "$user" my_file | awk '{ print $3}' | sed -e "s/\'//" | sed -e "s/;//"
1/ open my_file and only display lines containing "$user"
2/ display the 3rd item on the line
3/ remove the single quotes and the ;
I'm sure it can be optimized a bit but basically, that'll do what I
assume you want.
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[email protected]"