08-14-2007
Overwrite & Delete in Text File
Dear All,
I have text file like this:
Header
Record 1
Record 2
.......
Record n
Tail
This line of code :
awk '{ if ( NR == 1 ) { head=substr($0,1,300);} else { last = substr($0,1,300);}END{printf "Header is : %-300s Trailer is : %-300s\n", head, last}' filename
converted Header and Trailer in one line and within 300 character each.The output is just one line.
Now I want to overwrite this one line above (Header+ Tail) over the first line of original file (orginal header) and delete the Tail........i can copy this header and tail to new file and then append Record 1 to Record n to this new file, but that will cause too low performance........so I think better to update first and the last line of the this file.................so how can i do that?
i.e. 1-update the header with new line i.e. (header+trailer)
2-delete the tail in original file (may be using cut tail -1 filename?)
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a file in which email messages are stored in. Every email is separated by by a ^Z character (Control-Z).
I need to extract all emails after the 65,00th one to another file and delete them from the original file.
Any suggests on accomplishing this? (2 Replies)
Discussion started by: maxcell
2 Replies
2. Shell Programming and Scripting
I'm debugging a ksh script written by someone else that does the following:
It runs a command and redirects stdout to a file called dberror that already exists using ">". This command fails with the following error:
The file access permissions do not allow the specified action. dberror:... (1 Reply)
Discussion started by: savage66
1 Replies
3. Shell Programming and Scripting
Hello,
I'm trying the solve the following problem.
I have a file which I intend to use as a csv called master.csv
The columns are separated by commas.
I want to change the text on a specific row in either column 3,4,5 or 6 from xxx to yyy depending upon if column 1 matches a specified pattern.... (3 Replies)
Discussion started by: cyphex
3 Replies
4. Red Hat
ENVIROMENT
Linux: Fedora Core release 1 (Yarrow)
iPlanet: iPlanet-WebServer-Enterprise/6.0SP1
Log Path: /usr/iplanet/servers/https-company/logs
I have iPlanet log rotation enabled rotating files on a daily basis.
The rotated logs are NOT compressed & are taking up too much space.
I... (7 Replies)
Discussion started by: zachs
7 Replies
5. Shell Programming and Scripting
Hello All,
I had just a question about my Bash Script I'm currently writing.
The script I have writes some text to a output file. After I write to the output file I send the file to another server to do
some stuff with it.
After the file sends in the script, I don't need the output/txt... (4 Replies)
Discussion started by: mrm5102
4 Replies
6. Shell Programming and Scripting
I have 2 TXT files with with 8 columns in them(tab separated). First file has 2000 entries whereas 2nd file has 300 entries.
The first file has ALL the lines of second file. Now I need to remove those 300 lines (which are in both files) from first file so that first file's line count become... (2 Replies)
Discussion started by: prvnrk
2 Replies
7. Shell Programming and Scripting
I have ssh password less auth enable & script does the job well as well
#/bin/bash
for i in `cat ip`
do
scp /etc/resolv.conf root@$ip
done
But I need to take backup of the file i will overwrite .. is there any simple way ?
Kindly respond (5 Replies)
Discussion started by: heman96
5 Replies
8. UNIX for Dummies Questions & Answers
Hi Folks,
I am a novice and need to build a script in bash. I have 2 text files data.txt file is big file, column 2 is the we need to search and delete in the output. The filter file contains the rows to be deleted.
Data.txt
state city zone
Alabama Huntsville 4
California SanDiego 3... (3 Replies)
Discussion started by: tech_frk
3 Replies
9. Shell Programming and Scripting
ENVIROMENT
Linux: RHEL 6.4
Log Path: /usr/iplanet/servers/https-company/logs
Log Format: user.log.03-15-2015
I have log4j log rotation enabled rotating files on a daily basis.
The rotated logs are NOT compressed & are taking up too much space.
I need a script that will run daily that... (1 Reply)
Discussion started by: admin_job_admin
1 Replies
10. Shell Programming and Scripting
Hi All,
Do you have any sample script,
- auto get file from SFTP remote server and delete file in remove server after downloaded.
- only download specify filename
- auto upload file from local to SFTP remote server and delete local folder file after uploaded
- only upload specify filename
... (3 Replies)
Discussion started by: weesiong
3 Replies
LEARN ABOUT DEBIAN
svn::dump::record
SVN::Dump::Record(3pm) User Contributed Perl Documentation SVN::Dump::Record(3pm)
NAME
SVN::Dump::Record - A SVN dump record
SYNOPSIS
# SVN::Dump::Record objects are returned by the next_record()
# method of SVN::Dump
DESCRIPTION
An "SVN::Dump::Record" object represents a Subversion dump record.
METHODS
"SVN::Dump" provides the following gourps of methods:
Record methods
new()
Create a new empty "SVN::Dump::Record" object.
type()
Return the record type, as guessed from its headers.
The method dies if the record type cannot be determined.
set_header( $h, $v )
Set the header $h to the value $v.
get_header( $h )
Get the value of header $h.
set_property( $p, $v )
Set the property $p to the value $v.
get_property( $p )
Get the value of property $p.
delete_property( @k )
Delete the
set_text( $t )
Set the value of the text block.
get_text()
Get the value of the text block.
Inner blocks manipulation
A "SVN::Dump::Record" is composed of several inner blocks of various kinds: "SVN::Dump::Headers", "SVN::Dump::Property" and
"SVN::Dump::Text".
The following methods provide access to these blocks:
set_headers_block( $headers )
get_headers_block()
Get or set the "SVN::Dump::Headers" object that represents the record headers.
set_property_block( $property )
get_property_block()
Get or set the "SVN::Dump::Property" object that represents the record property block.
delete_property( @keys )
Delete the given properties. Behave like the builtin "delete()".
set_text_block( $text )
get_text_block()
Get or set the "SVN::Dump::Text" object that represents the record text block.
set_included_record( $record )
get_included_record()
Some special record are actually output recursiveley by svnadmin dump. The "record in the record" is stored within the parent record,
so they are parsed as a single record with an included record.
"get_record()" / "set_record()" give access to the included record.
According to the Subversion sources (subversion/libsvn_repos/dump.c), this is a "delete original, then add-with-history" node. The dump
looks like this:
Node-path: tags/mytag/myfile
Node-kind: file
Node-action: delete
Node-path: tags/mytag/myfile
Node-kind: file
Node-action: add
Node-copyfrom-rev: 23
Node-copyfrom-path: trunk/myfile
Note that there is a single blank line after the first header block, and four after the included one.
update_headers()
Update the various "...-length" headers. Used internally.
You must call this method if you update the inner property or text blocks directly, or the results of "as_string()" will be
inconsistent.
Information methods
has_prop()
Return a boolean value indicating if the record has a property block.
has_text()
Return a boolean value indicating if the record has a text block.
has_prop_only()
Return a boolean value indicating if the record has only a property block (and no text block).
has_prop_or_text()
Return a boolean value indicating if the record has a property block or a text block.
property_length()
Return the length of the property block.
text_length()
Return the length of the text block.
Output method
as_string()
Return a string representation of the record.
Warning: dumping a record currenly gives back the information that was read from the original dump. Which means that if you modified
the property or text block of a record, the headers will be inconstent.
ENCAPSULATION
When using "SVN::Dump" to manipulate a SVN dump, one should not directly access the "SVN::Dump::Headers", "SVN::Dump::Property" and
"SVN::Dump::Text" components of a "SVN::Dump::Record" object, but use the appropriate "set_...()" and "get_...()" methods of the record
object.
These methods compute the appropriate modifications of the header values, so that the "as_string()" method outputs the correct information
after any modification of the record.
SEE ALSO
"SVN::Dump::Headers", "SVN::Dump::Property", "SVN::Dump::Text".
COPYRIGHT
Copyright 2006-2011 Philippe 'BooK' Bruhat, All Rights Reserved.
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2011-03-22 SVN::Dump::Record(3pm)