I have a text file containing numbers as follows:
one two three four five six seven nine
I want to convert it into its equivalent digits like:
12345679
I got the python program.
Is there any way to do it using shell script?
Thanks in advance.
Create a dictionary that maps strings to values:
d = {'zero':'0',
'one':'1',
'two':'2',
'three':'3',
'four':'4',
'five':'5',
'six':'6',
'seven':'7',
'eight':'8',
'nine':'9'}
Pass the sequence of words through the dictionary and join the resultant list and turn it into an integer.
s = 'one two three four five six seven nine'
sequence = s.split(' ')
int(''.join([d[word] for word in sequence]))