Hello
I have the next problem. I have a output with this format:
msgs Kbytes last msg partition quotaroot mailbox path and acl
211 28706 2012/07/21 01:38 SERVER12 32768 user/XXXX/INBOX /SERVER01-02/=user/01/f0/=XXXXX XXXXX lrswipcda
0 0 2008/09/17 09:09 SERVER12 - user/XXXXX/Enviats /SERVER01-02/=user/01/f0/=XXXXX/=+Enviats XXXXX lrswipcda
I need to do a cut:
/SERVER01-02/=user/01/f0/=XXXXX
But the number of characters is different betwen lines
I trie use nawk (awk doesn't work in this version of solaris) unsuccessful.
Could you helpme?
Thanks
---------- Post updated at 06:10 AM ---------- Previous update was at 05:25 AM ----------
Mmm I'm trying and:
nawk '/busti/{print $8}' ruta.txt
With this result
/SERVER01-02/=user/36/85/=USER1
/SERVER01-02/=user/36/85/=USER1/=+Enviats
/SERVER01-02/=user/36/85/=USER1/=+Esborranys
/SERVER01-02/=user/36/85/=USER1/=+Paperera
/SERVER01-02/=user/81/97/=USER2
/SERVER01-02/=user/81/97/=USER2/=+Eliminats
/SERVER01-02/=user/81/97/=USER2/=+Enviats
/SERVER01-02/=user/81/97/=USER2/=+Esborranys
I only need extracts
/SERVER01-02/=user/36/85/=USER1
/SERVER01-02/=user/81/97/=USER2
Could you helpme?
Thanks
nawk '/busti/ && match($8,/(\/[^\/]*){5}/) {print substr($8,RSTART,RLENGTH)}' ruta.txt
1 Like
Thanks but doesn't work
root@SERVER01:/opt/scripts\ > nawk '/busti/ && match($8,/(\/[^\/]*){5}/) {print substr($8,RSTART,RLENGTH)}' ruta2.txt
root@SERVER01:/opt/scripts\ >
root@SERVER01:/opt/scripts\>vi ruta2.txt
/SERVER01-01/=user/a3/85/=USER1
/SERVER01-01/=user/a3/85/=USER1/=+Eliminats
/SERVER01-01/=user/a3/85/=USER1/=+Enviats
/SERVER01-01/=user/a3/85/=USER1/=+Esborranys
/SERVER01-02/=user/c6/30/=USER2
/SERVER01-02/=user/c6/30/=USER2/=+Eliminats
/SERVER01-02/=user/c6/30/=USER2/=+Enviats
/SERVER01-02/=user/c6/30/=USER2/=+Esborranys
/SERVER01-02/=user/84/60/=USER3
/SERVER01-02/=user/84/60/=USER3/=+Eliminats
/SERVER01-02/=user/84/60/=USER3/=+Enviats
/SERVER01-02/=user/84/60/=USER3/=+Esborranys
Run the command on the original file (I think it's ruta.txt)..not on the records you've extracted. And, awk, by no means, will change your original file, you'll need to redirect the output somewhere.
Thanks Elixir
Yes, I run the command on the original ruta.txt, with the same result. Any result
The origina ruta.txt contains:
0 0 2012/07/23 10:47 SERVER12 32768 user/USER1/INBOX /SERVER01-02/=user/c6/30/=USER1 USER1 lr
swipcda
0 0 2012/07/18 14:18 SERVER12 - user/USER1/Eliminats /SERVER01-02/=user/c6/30/=USER1/=+Eliminats 790
991670 lrswipcda
183 6659 2012/07/18 14:18 SERVER12 - user/USER1/Enviats /SERVER01-02/=user/c6/30/=USER1/=+Enviats 7909916
70 lrswipcda
0 0 2012/07/17 11:34 SERVER12 - user/USER1/Esborranys /SERVER01-02/=user/c6/30/=USER1/=+Esborranys 7
90991670 lrswipcda
msgs Kbytes last msg partition quotaroot mailbox path and acl
msgs Kbytes last msg partition quotaroot mailbox path and acl
msgs Kbytes last msg partition quotaroot mailbox path and acl
msgs Kbytes last msg partition quotaroot mailbox path and acl
msgs Kbytes last msg partition quotaroot mailbox path and acl
0 0 2011/03/08 11:50 SERVER12 32768 user/USER2/INBOX /SERVER01-02/=user/84/60/=USER2 USER2 lrswipcda
0 0 2008/09/16 11:36 SERVER12 - user/USER2/Eliminats /SERVER01-02/=user/84/60/=USER2/=+Eliminats dblan
coo lrswipcda
0 0 2008/09/16 11:36 SERVER12 - user/USER2/Enviats /SERVER01-02/=user/84/60/=USER2/=+Enviats USER2 lrswipcda
0 0 2008/09/16 11:36 SERVER12 - user/USER2/Esborranys /SERVER01-02/=user/84/60/=USER2/=+Esborranys dbl
ancoo lrswipcda
msgs Kbytes last msg partition quotaroot mailbox path and acl
msgs Kbytes last msg partition quotaroot mailbox path and acl
0 0 2009/10/20 12:29 SERVER11 32768 user/USER3/INBOX /SERVER01-01/=user/76/16/=USER3 USER3 lrswipcda
0 0 2008/09/16 12:20 SERVER11 - user/USER3/Eliminats /SERVER01-01/=user/76/16/=USER3/=+Eliminats elaca
rta lrswipcda
0 0 2008/09/16 12:20 SERVER11 - user/USER3/Enviats /SERVER01-01/=user/76/16/=USER3/=+Enviats USER3 lrswipcda
0 0 2008/09/16 12:20 SERVER11 - user/USER3/Esborranys /SERVER01-01/=user/76/16/=USER3/=+Esborranys ela
After to do
nawk '/busti/{print $8}' ruta.txt > ruta2.txt
The result is:
/SERVER01-01/=user/a3/85/=USER1
/SERVER01-01/=user/a3/85/=USER1/=+Eliminats
/SERVER01-01/=user/a3/85/=USER1/=+Enviats
/SERVER01-01/=user/a3/85/=USER1/=+Esborranys
/SERVER01-02/=user/c6/30/=USER2
/SERVER01-02/=user/c6/30/=USER2/=+Eliminats
/SERVER01-02/=user/c6/30/=USER2/=+Enviats
/SERVER01-02/=user/c6/30/=USER2/=+Esborranys
/SERVER01-02/=user/84/60/=USER3
/SERVER01-02/=user/84/60/=USER3/=+Eliminats
/SERVER01-02/=user/84/60/=USER3/=+Enviats
/SERVER01-02/=user/84/60/=USER3/=+Esborranys
If exceute your command, the result is:
root@SERVER01:/opt/scripts\ > nawk '/busti/ && match($8,/(\/[^\/]*){5}/) {print substr($8,RSTART,RLENGTH)}' ruta.txt
root@SERVER01:/opt/scripts\ >
Thanks for your reply. I continued researching
I can't see "busti" in "ruta.txt"...how did you get "ruta2.txt"?
Yes yes, sorry. I change the name of the servers & partitions for security. Inside ruta.txt:
msgs Kbytes last msg partition quotaroot mailbox path and acl
0 0 2011/03/08 11:50 bustia12 32768 user/USER1/INBOX /bustia01-02/=user/84/60/=USER1 USER1 lrswipcda
0 0 2008/09/16 11:36 bustia12 - user/USER1/Eliminats /bustia01-02/=user/84/60/=USER1/=+Eliminats lrswipcda
0 0 2008/09/16 11:36 bustia12 - user/USER1/Enviats /bustia01-02/=user/84/60/=USER1/=+Enviats USER1 lrswipcda
0 0 2008/09/16 11:36 bustia12 - user/USER1/Esborranys /bustia01-02/=user/84/60/=USER1/=+Esborranys d lrswipcda
msgs Kbytes last msg partition quotaroot mailbox path and acl
msgs Kbytes last msg partition quotaroot mailbox path and acl
Sorry I do replacement for security
OK. Will you try like this?
nawk '/busti/ && match($8,/\/[^\/]*\/[^\/]*\/[^\/]*\/[^\/]*\/[^\/]*/) {print substr($8,RSTART,RLENGTH)}' ruta.txt
bash-3.2$ cat b.txt
/SERVER01-01/=user/a3/85/=USER1
/SERVER01-01/=user/a3/85/=USER1/=+Eliminats
/SERVER01-01/=user/a3/85/=USER1/=+Enviats
/SERVER01-01/=user/a3/85/=USER1/=+Esborranys
/SERVER01-02/=user/c6/30/=USER2
/SERVER01-02/=user/c6/30/=USER2/=+Eliminats
/SERVER01-02/=user/c6/30/=USER2/=+Enviats
/SERVER01-02/=user/c6/30/=USER2/=+Esborranys
/SERVER01-02/=user/84/60/=USER3
/SERVER01-02/=user/84/60/=USER3/=+Eliminats
/SERVER01-02/=user/84/60/=USER3/=+Enviats
/SERVER01-02/=user/84/60/=USER3/=+Esborranys
bash-3.2$ nawk '{n=split($1,a,"/");if(n==6)print $1}' b.txt
/SERVER01-01/=user/a3/85/=USER1
/SERVER01-02/=user/c6/30/=USER2
/SERVER01-02/=user/84/60/=USER3