Hello
My file looks like that =>
12.56 have then 7888778.2566 what 44454.54545
878787.66565 if else 4445.54545455
I want to change all '.' on ',' .
I'm trying to do it with sed but I don't know chow to build regular expression to
change 454.4466 on 454,4466 ?
tr '.' ',' < infile > outfile
sed 's/\./,/g'
Got to put a backslash before "." to indicate an actual dot.
sed 's/\./,/g' - the command change all '.' on ',' in the file , but I want change
only dots in numbers .
sed 's/[0-9]\.[0-9]/,/g' filename
anbu23
6
sed -e "s/\([0-9]\)\./\1,/g" -e "s/\.\([0-9]\)/,\1/g" file
anbu23
7
This will remove numbers before and after dot
this wont work, as single digit is considered
echo "1234.23" | sed 's/\([0-9]*\)\.\([0-9]*\)/\1,\2/'
anbu23
9
$ echo dfd.dfd | sed 's/\([0-9]*\)\.\([0-9]*\)/\1,\2/'
dfd,dfd
Yes.it was a mistake...
sed 's/\([0-9]\)\.\([0-9]\)/\1,\2/g' filename
should be fine
Yeah, catch!
perl -e ' while (<>) { chomp; if( $_ =~ /(\d+)\.(\d+)/ ) { s/\./,/g; print "$_\n"; } else { print "$_\n" } }' filename
What is the need to replace number and ' . ' as number and ' , '
or
' . ' and number as ' , ' and number in a combined expression
just one of the them would do,
sed "s/\([0-9]\)\./\1,/g" a
or
sed "s/\.\([0-9]\)/,\1/g" a
anbu23
13
It wont work in the following cases
$ echo ".34" | sed "s/\([0-9]\)\./\1,/g"
.34
$ echo "23." | sed "s/\.\([0-9]\)/,\1/g"
23.
this is cool!
It didnt strike for me about the ".34" and "34." kind of numbers
perl -e ' while (<>) { chomp; if( $_ =~ /(\d+)\.(\d+)/ || $_ =~ /\.(\d+)/ || $_ =~ /(\d+)\./ ) { s/\./,/g; print "$_\n"; } else { print "$_\n" } }' filename