Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why my file is truncate ?

Status
Not open for further replies.

delphinelep

Programmer
Oct 14, 2004
2
FR


I have this problem

here is my first file


Code:
1025#1025#N#N#1#100#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#1#150#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#1#200#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#250#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#300#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#350#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#600#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1026#1026#N#N#1#100#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1026#1026#N#N#1#150#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1026#1026#N#N#1#200#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1026#1026#N#N#1#250#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1026#1026#N#N#1#300#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1026#1026#N#N#1#350#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1028#1028#N#N#1#100#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1028#1028#N#N#1#150#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1028#1028#N#N#1#200#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1028#1028#N#N#1#250#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1028#1028#N#N#1#300#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1028#1028#N#N#1#350#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1028#1028#N#N#1#400#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#1#250#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#1#300#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#1#350#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#100#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#150#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#200#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#400#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#450#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#500#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
1025#1025#N#N#2#550#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38


Here is what my program made

if field 1 contain 1025 then I replace it by 'XXXXXX'


Code:
cat -u ../LOG_ARCH/test.txt | awk -F'#' '{
# si le champ1 contient le numéro 1025
if ($1=='1025')
{
$1="XXXXXXX"
OFS="#"
print $0
}
}' > ../LOG_ARCH/test.txt



The problem is that my output file is truncate .


Code:
XXXXXXX#1025#N#N#1#100#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#1#150#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#1#200#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#250#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#300#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#350#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#600#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#1#250#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#1#300#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#1#350#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#100#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#150#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#200#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#400#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#450#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#1025#N#N#2#500#0#001#19755#12589#10000004#45712#AB#192121#terminal#test1#test2#test4#test5#test6#test7#test8#test9#test10#test34#test38
XXXXXXX#10



Why ? And how can I correct this problem

Thanks for your answers,
 
hi,
not sure if this is the reason, but:
reading from and writing to the same file never is a good idea.
So try different file names.
hth
 
I have to work on the same file.

I think , that this problem is du to the input file size only, because when my input file contain few lines only it work's good.
 
Hi,
I don't think that you have to work on the same file.
If filenames have to be preserved:
The usual way is to use a temporary file for output,
and do a mv afterwards.
regards
 
Code:
ex - myFile <<EOF
%s/^1025#/XXXXXXX#/g
wq!
EOF


vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Another issue is that in your awk program you discard all record not having $1==1025

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top