i have a file in follwing format
0110
1020
1011
1032
1020
2005
2003
1050
i want the output in such a way that all non zero numbers will be converted into 1
like this
0110
1010
1011
1011
1010
1001
1001
1010
how can i do so ?
Thanks in advance
I do not see your logic for 'non-zero' conversion.
Please define EXACTLY what you are doing for that conversion.
BTW 'non-zero' is any number 1,2,3...9 if you mean turn number > 1 into 1:
sed 's/[2-9]/1/g' oldfile > newfile
kurumi
4
$ ruby -ne 'print $_.gsub(/[2-9]/,"1")' file
0110
1010
1011
1011
1010
1001
1001
1010
or
$ ruby -ne 'print $_.tr("[2-9]","1")' file