greping word after new line character

how grep all user from the below looking file:

User_Alias      ADMIN1 = horacel, matthes, caseyl, alexl2, \
                         jackl, johnnyzh, maheshm, jihuih, davidw, \
                         christh, williaml,jasminez
User_Alias      ADMIN2 = tomc, apitssc, fengh, guh, kail, saizhuzh, \
                        terryl, timg, xiaowens, xiaoyeh, haitaow,haiyanx, \
                        liliangc, xiaohuiq, yuanyuan, huizh, juanw, \
                        liangyou, akandasw, babukart, veerasam, pothann, \
                        thamodar, mramesh, mrenjith

User_Alias      TCSADMS = ramachv, manojid, saravac, jasons, abubaks, \
                          girishb, ramachp, arindab, ericli, nandak
cat <FILE> | sed '/\\$/N; s/[\\\n]//g; s/  */ /g ' | grep <USER>
echo `cat Users.txt | cut -d= -f2` | awk '!x[$0]++' |awk -F"[,]" '{ for (i=1; i<=NF; i++) print $i }'

it will handle upto comma.. But i am sorry i couldn't handle escape charactor.

.

Not get the desided output .. Pls help

  1. Please use complete english words and sentences.
  2. "Not get the desided output"? You never told us what output you expect. Or how the output from those commands is different from what you expect. We ain't psychic.

Exactly Pludi..

Your heading of the post "greping word after new line character"
and "how grep all user from the below looking file:" it self different.

if posting , please provide us how you want your OUTPUT exactly or how your OUTPUT will look like atleast.

.

Sorry guys.seems my requirement is not clear to the forum. My requirement is I want to get only the listing of user id from the pasted text as below. once I grep User_Alias only the first line of user I'm able to get but not the other user which are separated by "\" new line character. Pls help..
horacel
matthe
caseyl
alexl2jackl
johnnyzh
maheshm
jihuih
davidw

I believe you'll need sed or awk to help. Given your input, this sed

sed -n -r '/\\$/ { s/\\$//; H; b; }; x; G; s/\n//g; s/,[ \t]*/,/g; p; s/.//g; h'<input-file

will concatenate all lines that have a terminating backslant (\) and close spaces that follow commas. Output would be all lines and the alias lines would be like this:

User_Alias      ADMIN1 = horacel,matthes,caseyl,alexl2,jackl,johnnyzh,maheshm,jihuih,davidw,christh,williaml,jasminez

Lines that don't have a final backslant will have any blanks following commas deleted, but I think that is an ok side effect here.

If you are looking for one set of users, then you can add a grep, and maybe a sed to delete the leading constant part, and put each user name on a new line.

 
sed -n -r '/\\$/ { s/\\$//; H; b; }; x; G; s/\n//g; s/,[ \t]*/,/g; p; s/.//g; h' <input-file | grep ADMIN1|sed 's/^.*= *//; s/,/\n/g'

Not yet get the desired output. The input files is having userid in diffrerent line as below:

User_Alias      ADMIN1 = horacel,matthes,caseyl,alexl2,\
                         jackl,johnnyzh,maheshm,jihuih,davidw,\
                         christh,williaml,jasminez

so while greping ADMIN1 we are getting the first lines only as part of ADMIN1 group as below

horacel,matthes,caseyl,alexl2,\

but we need all the user id as below

horacel,matthes,caseyl,alexl2, jackl,johnnyzh,maheshm,jihuih,davidw,christh,williaml,jasminez
% ADMIN=ADMIN1; perl -lne '$s .= $_;  
  if (!/\\$/) {
        $s =~ s/ |\\//g;
        $s =~ /'$ADMIN'/ && $s =~ s/^.*'$ADMIN'=// && print $s;
        $s=""}' testfile
horacel,matthes,caseyl,alexl2,jackl,johnnyzh,maheshm,jihuih,davidw,christh,williaml,jasminez

See, was that so hard? Give us enough information, and we'll be able to help you. Ask ambiguous questions, and you'll get answers that aren't helpful at all.

Save this as a file, and invoke it as perl script.pl -group=<Group you're looking for> <sudoers file>

#!/usr/bin/perl -Ws

use strict;
use warnings;

local $/;
our $group;

my $file = <>;

if ( $file =~ /User_Alias\s+$group\s+=\s+(.+?)[^\\]$/ms ) {
    my $users = $1;
    $users =~ s/[\n \\]//g;
    print $users, "\n";
}

Could be shortened to a single line, but that would be fugly and untypeable.