my requirement:
read txt file and if not empty do something.
I notice that on one unix server, i use vi to create an empty file, but the file size is 1, not 0. the bottom of the vi editor says the file has '1 line, 1 character' although i did a 'dd' and made sure the file is empty.
On another unix box, i am able to create a txt file using vi again that shows a size of 0.
is this really happening or am i doing something wrong here??!! I know this is an odd kind of question but i am a unix newbie and am hoping some expert can shed some light on this.... i cant leave it to unix servers or versions whatever being different cos in the end, it has to work 'no matter what'!
So basically, doing a "test ! -s" may not be the best way to go for me... is there a better and safer way to check for empty txt files.
read txt file and if not empty do something.
I notice that on one unix server, i use vi to create an empty file, but the file size is 1, not 0. the bottom of the vi editor says the file has '1 line, 1 character' although i did a 'dd' and made sure the file is empty.
On another unix box, i am able to create a txt file using vi again that shows a size of 0.
is this really happening or am i doing something wrong here??!! I know this is an odd kind of question but i am a unix newbie and am hoping some expert can shed some light on this.... i cant leave it to unix servers or versions whatever being different cos in the end, it has to work 'no matter what'!
So basically, doing a "test ! -s" may not be the best way to go for me... is there a better and safer way to check for empty txt files.