Question: In a slightly different question from [this other](https://stackoverflow.com/questions/33336086/bash-in-file-converting-first-field-of-a-text-file-from-decimal-to-hexadecimal), I would like to convert any number in a text file from **decimal to hexadecimal**. 

A number is here defined by `a set of numeric characters together`. 

Example:

```
$ cat MyFile.txt
Hello,10,Good255Bye-boys01

```

Must become:

```
Hello,0A,GoodFFBye-boys01

```

Valid too:

```
Hello,A,GoodFFBye-boys1

```

Methods that allow (first case) to specify the character wide (to obtain `0A` instead of `A`) are preferred.

I have tested `grep` to extract the numbers piped to `bc` to convert them:

```
( echo "obase=16" ; cat Line.txt  |grep -o '[0-9]*') | bc

```

but this method shows only one (converted to hex) number each line, and removes the rest of the characters.

Answer: 
Since you're okay with using `grep` and `bc` in a pipe, it's clear that you don't want a solution in pure `sh`, but are happy to use external tools. 

```
perl -pe 's/([0-9]+)/sprintf "%02X", $1/ge' myfile.txt

```
dec2hex command will do the task.