I'm able to do it in pieces through awk print $ 2, sed [az] etc., but how do I Is this all through a single stream on a single stream?
host_192.168.0.100 host_192.168.0.100 current
host_192.168.0.100 192.168. 0.100 In addition, 'host' is just a placeholder, I really want 'all' letters that leave numbers / punctuation marks. Edit: Underscore will be good to catch, but I'm sure I can understand that there are some other common examples: abababab-abababab- 000.000.000.0 ab-ab-abababab -abababab-000.000.000.0 01-admin-10.10.10.10 01-admin-10.10.10.10 10.10.10.10-NAT 10.10.10.10-NAT 1test-10.10.10.10 1test-10.10.10.10 Thanks!
Looking at the second example, it seems that you want to appear after the first white space To remove all non-digits, logically Git before the first DI. You need to remove dashes, underscores, even dots, as well as letters; Anything that is not a digit gives this suggestion:
sed -e 's / [^ 0-9] * / /' Quite easy, but meets your criteria:
$ cat data host_192.168.0.100 host_192.168.0.100 now-now-nowabbab-abababab-2000,000.000.0 Now-now- Ababab-Ababab-2000.000.000.0 $ sed -e '/ s [^ 0-9] * / /' data host_1 92.168.0.100 1982.18.100 al-abbabab-ababab-2000.000.000.0 000.000.000.0 $ < / Code> A good part is writing good writing of good regular expression in writing. If you really want to do regular expression (Understand regular expressions such words).
The three major items make life very complex, with numbers and letters, and the following content:
$ cat data host_192.168.0. 100 host_192.168.0.100 ab-ab-abababab-abababab-000.000.000 ab abbabab-abbabab -000.000.000.0 01-admin-10.10.10.10 01-admin-10.10.10.10 10.10.10.10-NAT 10.10.10.10- NAT 1test-10.10.10.10 1 Test-10.10.10.10 $ sed -e's / [^ 0- 9] * / / '\ & gt; -e s / [^.] * - \ ([0-9] [0-9.] * [0- 9] \) / \ 1 / '\ & gt; -Es / \ ([0-9] [0-9.] * [0-9] \) [^ 0-9.]. * $ / 1 / 'Data Host_1 92.168.0.100 192.168.0.100 Ab-ab-abababab-abababab-000.000.000.0 000.000.000.0 01-admin-10.10.10.10 10.10.10.10 10.10.10.10-NAT 10.10.10.10 1test-10.10. 10.10 10.10.10.10 $ sed The script receives 3 free clean expression before, as before, removes any non-digit immediately after the space is. It does not require tweaking. 01-admin - line though untouched by that; The second regular expression follows a blank, sequence of non-dots followed by a dash, and then occupy the starting sequence with one digit, continuing with the interleaved points and dots, and ending with a digit, with changing it Matching string dash, remembering points and points is important for that task; If you are not careful, then * is too greedy (for example, s /. * \ ([0-9] [0-9.] * [0-9] ) / \ 1 / key digit has been closed from the IP-address component). I'm assuming that sed does not have a non-greedy quantifier such as *? ; If your version does, you can come up with a different answer (but this version will also work) you may need to zoom that pattern to handle other extraordinary matters; Please do this for yourself, do not edit this question. The third regular expression deals with the following -NET and other such content; It remembers the sequence of digits and points (beginning and ending with the digits) and after that, remembering the digits and the points, instead of the string of memories, after a non-digit, non-dot character and any other trailing material is. It does not require much more tweaking.
No comments:
Post a Comment