Gentoo Archives: gentoo-user

From: "François-Xavier CARTON" <fx.carton@×××××.fr>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] OT scripting - strip zero if between period and digit
Date: Tue, 22 Jan 2019 02:07:04
Message-Id: 585c2f64-424a-ceb0-9ace-f1bf96a262fc@yahoo.fr
In Reply to: [gentoo-user] OT scripting - strip zero if between period and digit by Adam Carter
1 Le 22/01/2019 à 00:50, Adam Carter a écrit :
2 > I need to clean up a file which has IP addresses with leading zeros in
3 > some of the octets so I need to make, say, .09 into .9
4 >
5 > How do i do that in sed/awk/whatever?
6
7
8 I believe that should do:
9
10 sed 's/0*\([0-9]\)/\1/g'
11
12 eg.
13
14 $ sed 's/0*\([0-9]\)/\1/g' <<EOF
15 0.1.2.3
16 01.2.3.4
17 1.2.3.0
18 1.2.000.3
19 EOF
20 0.1.2.3
21 1.2.3.4
22 1.2.3.0
23 1.2.0.3
24
25 François-Xavier

Replies

Subject Author
Re: [gentoo-user] OT scripting - strip zero if between period and digit "François-Xavier CARTON" <fx.carton@×××××.fr>