data.txt has several information like the below..
<SERVER>:WEB:MYDOM01:/tmp/cong/MYDOM01,/tmp/app/MYDOM01
<WEBER>:CANES:https-web01,https-web02:/web/apps/https-web01/config
<SERVER>:WEB:MYDOM07:/tmp/cong/MYDOM07,/tmp/app/MYDOM07
<WEBER>:CANES:https-web06,https-web07:/web/apps/https-web07/config
.......
......
I need to read data.txt and pull out all physical paths like the below.
/tmp/cong/MYDOM01
/tmp/app/MYDOM01
/web/apps/https-web01/config
/tmp/cong/MYDOM07
/tmp/app/MYDOM07
/web/apps/https-web07/config
Need a quick way to achieve this same.
awk -v RS="[:,\n]" '/^\//' inputfile
Use nawk on solaris.
i get the below error:
awk -v RS="[:,\n]" '/^\//' data.txt
awk: syntax error near line 1
awk: bailing out near line 1
bash-3.2$ uname -a
SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v
corona688:
Use nawk on solaris.
I used nawk
but i dont see anything in the output. It's blank.
OK, you have an old awful awk which doesn't support regexes in the field separator.
How about:
tr ':,' '\n\n' < inputfile | grep '^/'
1 Like
corona688:
OK, you have an old awful awk which doesn't support regexes in the field separator.
How about:
tr ':,' '\n\n' < inputfile | grep '^/'
Works good !! Thank you Corona
1 Like
Aia
June 21, 2016, 11:32pm
8
Another alternative:
perl -nle 'while(/((?:\/[\w-]+)+)/g){print $1}' mohtashims.file
Output:
/tmp/cong/MYDOM01
/tmp/app/MYDOM01
/web/apps/https-web01/config
/tmp/cong/MYDOM07
/tmp/app/MYDOM07
/web/apps/https-web07/config