Hi every1
Well i have a list of numbers e.g
12304
13450
01234
00123
14567
what i want is a command to check if the number is starting from 0 and then delete the 0 without doing anything else!!!!
any help wud b appreciated!!!!!!!!
Hi every1
Well i have a list of numbers e.g
12304
13450
01234
00123
14567
what i want is a command to check if the number is starting from 0 and then delete the 0 without doing anything else!!!!
any help wud b appreciated!!!!!!!!
Removing only the first 0:
awk '{sub(/^0/,"")}1' list
I presume you want to delete all the leading zeroes, not only the first one, right? This the solution in sed:
sed 's/^00*//' /path/to/sourcefile > /path/to/resultfile
It should be said that both the awk- and the sed-solution are easily changed to achieve the respective other conceivable goal.
I hope this helps.
bakunin
using Perl:
perl -pi -e 's/^0+//' filename
Another one:
awk '{print int($0)}' file
Regards