File size changes on replacement of certain numbers


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers File size changes on replacement of certain numbers
# 1  
Old 07-04-2014
File size changes on replacement of certain numbers

I had a doubt regarding how the file size changes and needed some advice on the same


So I have this file say abc.txt.. Size was 10000. Now inside the file when I go and I replace all the number 7 numerals with number 4 file size changed to 9984. Any idea why and how ??
# 2  
Old 07-04-2014
replacing a single character with another will not change the size.
Check if you are removing spaces / new line characters
# 3  
Old 07-04-2014
Not replacing any space. This is the command I use

Code:
%s/20140707/20140704/g

# 4  
Old 07-04-2014
why dont you do the below.
If the original file is file1.txt of 10000 size, make a copy of it, do the changes and if you see the size is different, do a diff
# 5  
Old 07-04-2014
Quote:
Originally Posted by sidnow
Not replacing any space. This is the command I use

Code:
%s/20140707/20140704/g

Which program do you use to issue this command? If it is inside a "vi" session your editor might be configured to replace 8 consecutive spaces with a single tab character. Another possibility is that the file contains some control characters and the program you use to edit the file filters them out.

Copy the file before the editing session, edit it and then run a

Code:
diff /path/to/file1 /path/to/file2

to see the differences. This might give you at least an idea what happened.

I hope this helps.

bakunin
# 6  
Old 07-04-2014
Well diff wouldn't be of much help, because it would show me more than 1000 differences in the dates I replaced
# 7  
Old 07-04-2014
So you would have more than 1000 hints on what going on/wrong!

Do it on a smaller file, and analyze step by step.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding (as in arithmetic) to numbers in columns in file, and writing new file with new numbers

Hi again. Sorry for all the questions — I've tried to do all this myself but I'm just not good enough yet, and the help I've received so far from bartus11 has been absolutely invaluable. Hopefully this will be the last bit of file manipulation I need to do. I have a file which is formatted as... (4 Replies)
Discussion started by: crunchgargoyle
4 Replies

2. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

3. Programming

[c] How to calculate size of the file from size of the buffer?

Hi, Can I find size of the file from size of the buffer written? nbECRITS = fwrite(strstr(data->buffer, ";") + 1, sizeof(char), (data->buffsize) - LEN_NOM_FIC, fic_sortie); Thank You :) (1 Reply)
Discussion started by: ezee
1 Replies

4. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

5. Shell Programming and Scripting

Script to read file size and send email only if size > 0.

Hi Experts, I have a script like $ORACLE_HOME/bin/sqlplus username/password # << ENDSQL set pagesize 0 trim on feedback off verify off echo off newp none timing off set serveroutput on set heading off spool Schemaerrtmp.txt select ' TIMESTAMP COMPUTER NAME ... (5 Replies)
Discussion started by: welldone
5 Replies

6. Shell Programming and Scripting

The scripts not able to make the file to size 0, every times it go back to its original size

#!/bin/sh ########################################################################################################## #This script is being used for AOK application for cleaning up the .out files and zip it under logs directory. # IBM # Created #For pdocap201/pdoca202 .out files for AOK #1.... (0 Replies)
Discussion started by: mridul10_crj
0 Replies

7. Solaris

Directory size larger than file system size?

Hi, We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB? I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies

8. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

9. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies
Login or Register to Ask a Question