Those "strange characters" are escape sequences for coloring the output.
This will print that number in blue color:
echo -e '\033[01;34m1010729039145\033[0m'
man console_codes for more details.
You can tell
ls in which cases it shall output colors:
colorize the output; WHEN can be 'never', 'auto', or 'always' (the default); more info below
Looks like your
ls is actually an alias for
ls --color=always. (Type
type ls to verify.)
ls --color=auto will do the right thing: It will print colors on screen but no into files.
If you really want the color in your file, your have to decide, if you want to see the actual escape sequences or the interpreted colors.
For example the
less command will default to printing the actual sequences, but you can tell it to show the colors instead with the
-R or --RAW-CONTROL-CHARS
Like -r, but only ANSI "color" escape sequences are output in "raw" form.
less textfile vs.
less -R textfile.