get specific information from text file or command output

Hello,

I would need some help, :wall: on a linux script,

I am not sure how can I separate some text file,

Text file contains something similar to this:
share "userhome_e" "/fs1_100g/FILE58/userhome" umask=022 maxusr=4294967295 netbios=FILE58
share "bu share" "/fs3_100g/FILE36/userhome" umask=022 maxusr=4294967295 netbios=FILE36

I would need to grab the sharename which is "userhome_e" and the server which is FILE58,
And make it appear as \\FILE58\userhome_e,/fs1_100g/FILE58/userhome
and \\file36\bu share,/fs3_100g/FILE36/userhome

I will appareciate any help,

This makes some assumptions about the input (like netbios= always being the last on the line), but might work:

awk -F '"' '
    /share/ {
        n = split( $0, a, "=" );
        printf( "\\\\%s\\\\%s,%s\n", a[n], $2, $4 );

    }
' input-file >output-file
1 Like
awk -F"\"" '/^share/{n=split($NF,a,"=");print "\\"a[n]"\\"$2","$4}' filename
1 Like

Thank you both guys, you resolved my issue.