olifu02
February 9, 2012, 11:56am
1
Hi,
I columns with both number and letters however i need the number 4 trimmed off the lines that have 3 numbers in them so it just because the 2 preceding numbers only
For example
V25QG2-K18QG-V25CG2
L26HG-L17HA-L26CG
I434QD1-L19HB2-I434CD1
I434QD1-A31QB-I434CD1
I435QD1-E32QG-I435CD1
needs to be
V25QG2-K18QG-V25CG2
L26HG-L17HA-L26CG
I34QD1-L19HB2-I34CD1
I34QD1-A31QB-I34CD1
I35QD1-E32QG-I35CD1
thanks so much.
perl -pe 's/4(\d\d)/$1/g' file
ctsgnb
February 9, 2012, 2:03pm
3
sed 's/4\([0-9][0-9]\)/\1/g' file
olifu02
February 10, 2012, 10:25am
4
How can i make either of those work in only the first column?
awk -F- '$1~/4[0-9]{2}/{sub(/4/,x)}1' infile
-or-
sed 's/^\([^-]*\)4\([0-9][0-9]\)/\1\2/' infile
but perhaps this is enough:
sed '/^.4/s/.//2' infile
olifu02
February 10, 2012, 11:11am
6
im sorry i may have mislead you guys
i need
A431QB-A31HA-A431CB 1.429 3.936 17.212
to
A31QB-A31HA-A31CB 1.429 3.936 17.212
but the first two answers in the thread would delete the .429 as well which i dont want.
Thanks all
Try:
perl -nle '/(\S+)(.*)/;$y=$2;$_=$1;s/4(\d\d)/$1/g;print "$_$y"' file
ctsgnb
February 10, 2012, 6:58pm
9
sed 's/4\([0-9][0-9][A-Z]\)/\1/g' file
sed 's/4\(..[A-Z]\)/\1/g' file
sed 's/\([A-Z]\)4/\1/g' file