Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Binary line being inserted while truncating a file Post 302353261 by pludi on Tuesday 15th of September 2009 02:56:58 AM
Old 09-15-2009
You've got to give us some more information on how you truncate the file, what kind of link you use, and what and how another application might write into that file, because I can't yet reproduce that behaviour:
Code:
bash-3.2$ perl -e 'for($i=0;$i<100;$i++){print chr(ord('A')+$i%26)x40,"\n";}' > test1.txt
bash-3.2$ ln -s test1.txt test2.txt
bash-3.2$ ln test1.txt test3.txt
bash-3.2$ ll test*.txt
-rw-r--r-- 2 pludi users 4100 15. Sep 08:53 test1.txt
lrwxrwxrwx 1 pludi users    9 15. Sep 08:53 test2.txt -> test1.txt
-rw-r--r-- 2 pludi users 4100 15. Sep 08:53 test3.txt
bash-3.2$ head test1.txt
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
bash-3.2$ head test2.txt
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
bash-3.2$ head test3.txt
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
bash-3.2$ : > test1.txt
bash-3.2$ head test1.txt
bash-3.2$ head test2.txt
bash-3.2$ head test3.txt
bash-3.2$ ll test*.txt
-rw-r--r-- 2 pludi users 0 15. Sep 08:54 test1.txt
lrwxrwxrwx 1 pludi users 9 15. Sep 08:53 test2.txt -> test1.txt
-rw-r--r-- 2 pludi users 0 15. Sep 08:54 test3.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

truncating leading zeros of a column in a file

Hi I have a file in which I have 5 columns which are delimited by “|” as shown ABC|12|YAK|METRIC|000000019.5 XYZ|10|ABX|META|000000002.5 Now my requirement is to take the last column trim the leading zero's for that column values and write back to the same file in the same... (7 Replies)
Discussion started by: nvuradi
7 Replies

2. Shell Programming and Scripting

Truncating FILE data BASED ON A PATTERN

HI I HAVE A PROBLEM,MY SOURCE FILE IS OF PATTERN S1,E-Certified,29,29,2.7,Certified,4,3,2.7,,0,0,0 S2,Certified,4,3,2.7,,0,0,0,,0 S3,E-Certified,29,29,2.7,,0,0,0 S4,,0,0,0,,0,0,0,,0,0,0,,0,0,0 AND THE EXPECTED OUTPUT IS S1,E-Certified,29,29,2.7 S1,Certified,4,3,2.7... (1 Reply)
Discussion started by: pkumar3
1 Replies

3. Shell Programming and Scripting

Removing inserted newlines from a fileld of fixed width file.

Hi champs! I have a fixed width file in which the records appear like this 11111 <fixed spaces such as 6> description for 11111 <fixed spaces such as 6> some more field to the record of 11111 22222 <fixed spaces such as 6> description for 22222 <fixed spaces such as 6> some more field to the... (8 Replies)
Discussion started by: enigma_1
8 Replies

4. UNIX for Dummies Questions & Answers

Truncating file based on date

Hi, I need to truncate a file based on date.Suppose i have a log file which is getting updated every date,i need to keep 7 days worth of data(like sysdate-7) and rest i want to truncate it.Can some help me? (5 Replies)
Discussion started by: Param0073
5 Replies

5. Shell Programming and Scripting

sed truncating last line if EOF is not with newline

sed 's|^xyz.abc *= *.*|xyz.abc=60|' /test/myFile.properties > /test/myFile.properties1 myFile.properties has the last line as xyz.abc=23 does not end with newline. When I run this command the last line is truncated if there is no newline character at EOF. Looking for an alternative here. (1 Reply)
Discussion started by: sunn_hps
1 Replies

6. Shell Programming and Scripting

script to detect a file from inserted usb and puts into a Variable

There is a same named log file that I have on my 2 different android phones. When I plug it into my computer, it appears in the media folder, For example the first android phone: /media/F6BA-0AF5/folder/A.log I want to put that into a variable to be manipulated.... (3 Replies)
Discussion started by: tobenguyen
3 Replies

7. Shell Programming and Scripting

How to avoid the truncating of multiple spaces into a single space while reading a line from a file?

consider the small piece of code while read line do echo $line done < example content of example file sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the output is like sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the... (4 Replies)
Discussion started by: Kesavan
4 Replies

8. Shell Programming and Scripting

Truncating a mail file

Hi, I have a Unix mail file that I need to truncate, based on the date of the messages. For those not familiar with the format, it is a single file for each user, with the first line of the mail message looking like the following: From user@sitename.com Thu Apr 21 05:40:33 2011 Each... (3 Replies)
Discussion started by: joed
3 Replies

9. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

10. Shell Programming and Scripting

How to add new line after every data inserted to file?

Hi all, I need help for solve my problem. my problem is like this.. i want to add many word to file. but after I add 1 word, the second word should be in the under of the first word. i have tried but the result is like this word1word2word3 i want the result to be like this word1 word2... (5 Replies)
Discussion started by: weslyarfan
5 Replies
Binary.getBlockChunk(3kaya)				       Kaya module reference				       Binary.getBlockChunk(3kaya)

NAME
Binary::getBlockChunk - Return a chunk from a block as an array. SYNOPSIS
[Int] getBlockChunk( Binary block, Int offset, Int bsize ) ARGUMENTS
block The binary block offset The offset to start at (zero-indexed) bsize The length of chunk to read DESCRIPTION
Return a chunk from a block as an array. Throws an Binary.OffsetOutOfRange(3kaya) Exception if it attempts to access a value outside the block. AUTHORS
Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/ LICENSE
The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation. RELATED
Binary.Binary(3kaya) Binary.array(3kaya) Binary.copyChunk(3kaya) Binary.peek(3kaya) Binary.peekString(3kaya) Binary.setBlockData(3kaya) Kaya October 2012 Binary.getBlockChunk(3kaya)
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy