![]() |
Bash script help
HI, i have a file with various numbers, but the file contains some numbers with leading zeros
01 02 03 04 how do i strip the leading zeros from the contents of the file????? having brain fart compounded by beer. |
If you are trying to get rid of the first character, then you could use 'cut'.
cut -b 2 file_one > file_two Else, you have to look at 'sed'. |
cat file | sed -e s/^0*//g > file.new
|
what are you using to bash with? sledgehammer or baseball bat?
|
Quote:
sed -i s/^0*//g filename Or you could use expr and add the numbers to 0, which will drop all insignificant digits for i in `cat file` do expr $i + 0 >> newfile done Although thats kinda sloppy... but depending on how the file is structured, may be required. |
thanks guys... :)
|
| All times are GMT -8. The time now is 02:04 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0
Copyright 2025 Pelican Parts, LLC - Posts may be archived for display on the Pelican Parts Website