Hi
I have file
128 BES-Exchange [perf08:storage1] BES-Exchange/BES-Exchange.vmx winNetEnterpriseGuest vmx-04
144 BES-SVR [perf08:storage1] BES-SVR/BES-SVR.vmx winNetEnterpriseGuest vmx-04
176 BES AD [perf08:storage1] BES-AD/BES AD.vmx winNetEnterpriseGuest vmx-04
so in above file i want to extract only BES AD
the BES AD is seperated by tab i tried with gawk but not getting exact what i want
I want following output
BES-Exchange
BES-SVR
BES AD
Thanks
Brahma
awk -F"[" '{print $1}' infile|cut -d' ' -f1 something like this
or instead of cut you can use sed also...
awk -F"[" '{print $1}'|sed -e 's/^ [^ ] //'
cat File.txt
128 BES-Exchange [perf08:storage1] BES-Exchange/BES-Exchange.vmx winNetEnterpriseGuest vmx-04
144 BES-SVR [perf08:storage1] BES-SVR/BES-SVR.vmx winNetEnterpriseGuest vmx-04
176 BES AD [perf08:storage1] BES-AD/BES AD.vmx winNetEnterpriseGuest vmx-04
awk -F"/|[.]" '{print $2}' File.txt
when i do this it gives me output as
128 BES-Exchange
144 BES-SVR
176 BES AD
i want only BES and things
the pipe it to cut or sed to remove first word as i suggested..
bp_vardhaman,
du tried awk -F"/|[.]" '{print $2}' File.txt this ?
But i even want tab also but here its coming as without tab ![:slight_smile: :slight_smile:](https://community.unix.com/images/emoji/apple/slight_smile.png?v=9)
BES AD
vmware-vim-cmd vmsvc/getallvms| grep -v Vmid | awk -F"[" '{print $1}' | sed -e 's/[ !0-9]*//'
Got the right one after doing this
Thanks everybody who helped
#!/bin/bash
while read -r line
do
line=${line%%[*}
set -- ${line}
echo $2
done < file
cat file | sed 's/\(.*\/\)\(.*\)\(\.vmx.*\)/\2/'