Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Hardcoding & Record counts in a file Post 302549233 by alister on Monday 22nd of August 2011 10:23:22 AM
Old 08-22-2011
Quote:
Originally Posted by shruthidwh
I am not sure how to insert the headers and the record count at the starting of the file, as the file is huge i don't want to copy the file and make the changes.

is there any way by which i can add the four lines which out duplicating the file.
Quote:
Originally Posted by yazu
No way. You have to make a new copy of the file explicitly or implicitly (perl or GNU sed with -i option).
That's incorrect. ed can be used to modify a file without creating another file in the filesystem.

The following may give the original poster some ideas:
Code:
filename=data
ed -s "$filename" <<EOED
1i
FILENAME = $filename
DATETIME = $(date +%Y%m%d%H%M%S)
RECORD_COUNT = $(awk 'END {print NR}' "$filename")
.
w
q
EOED

Caveat: It's never been a problem for me, but keep in mind that ed uses a single dot on a line by itself to delimit the data being inserted. Should the inserted data itself contain a dot by itself on a line, it would need to be protected with an unambiguous decoration. After the insertion, the substitute command can be used to undecorate.
 

10 More Discussions You Might Find Interesting

1. Solaris

file size counts??

Hello experts, I do - $ ls -lhtr logs2007* Is it possible that i can get the results of- totals size in MB/KB for ALL "logs2007*" note: in the same directory I have "logs2006*" & "logs2007*" files. (4 Replies)
Discussion started by: thepurple
4 Replies

2. UNIX for Dummies Questions & Answers

how to get a file name & record count of csv file

HI , I am new to shell scripting , I have a requirement that I send a file for data quality ( original.csv) & i will be getting 4 files daily into a particular directory in return with cleansed data . the files may be clean.csv, unclean.csv , ... (2 Replies)
Discussion started by: sirik
2 Replies

3. Shell Programming and Scripting

Sending e-mail of record counts in 3 or more files

I am trying to load data into 3 tables simultaneously (which is working fine). Then when loaded, it should count the total number of records in all the 3 input files and send an e-mail to the user. The script is working fine, as far as loading all the 3 input files into the database tables, but... (3 Replies)
Discussion started by: msrahman
3 Replies

4. Shell Programming and Scripting

New file should store all the 7 existing filenames and their record counts and ftp th

Hi, I need help regarding below concern. There is a script and it has 7 existing files(in a path say,. usr/appl/temp/file1.txt) and I need to create one new blank file say “file_count.txt” in the same script itself. Then the new file <file_count.txt> should store all the 7 filenames and... (1 Reply)
Discussion started by: pr293
1 Replies

5. Shell Programming and Scripting

Read record from the text file & assign those values to variables in the script

For eg: I have sample.txt file with 4 rows of record like: user1|password1 user2|password2 user3|password3 user4|password4 The username and password is sepsrated by '|' I want to get the 1st row value from the file and assign it to two different variables(username and password) in my... (1 Reply)
Discussion started by: priya001
1 Replies

6. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

7. Shell Programming and Scripting

Extract timestamp from first record in xml file and it checks if not it will replace first record

I have test.xml <emp><id>101</id><name>AAA</name><date>06/06/14 1811</date></emp> <Join><id>101</id><city>london</city><date>06/06/14 2011</date></join> <Join><id>101</id><city>new york</city><date>06/06/14 1811</date></join> <Join><id>101</id><city>sydney</city><date>06/06/14... (2 Replies)
Discussion started by: vsraju
2 Replies

8. Shell Programming and Scripting

Counts not matching in file

I can not figure out why there are 56,548 unique entries in test.bed. However, perl and awk see only 56,543 and that # is what my analysis see's as well. What happened to the 5 missing? Thank you :). The file is attached as well. cmccabe@DTV-A5211QLM:~/Desktop/NGS/bed/bedtools$wc -l... (2 Replies)
Discussion started by: cmccabe
2 Replies

9. Shell Programming and Scripting

CSV File:Filter duplicate records from column1 & another column having unique record

Hi Experts, I have csv file with 30, 40 columns Pasting just 2 column for problem description. Need to print error if below combination is not present in file check for column-1 (DocumentNumber) and filter columns where value in DocumentNumber field is same. For all such rows, the field... (7 Replies)
Discussion started by: as7951
7 Replies

10. Shell Programming and Scripting

Remove duplicated records and update last line record counts

Hi Gurus, I need to remove duplicate line in file and update TRAILER (last line) record count. the file is comma delimited, field 2 is key to identify duplicated record. I can use below command to remove duplicated. but don't know how to replace last line 2nd field to new count. awk -F","... (11 Replies)
Discussion started by: green_k
11 Replies
Mail::SPF::v2::Record(3)				User Contributed Perl Documentation				  Mail::SPF::v2::Record(3)

NAME
Mail::SPF::v2::Record - Sender ID ("spf2.0") record class SYNOPSIS
See Mail::SPF::Record. DESCRIPTION
An object of class Mail::SPF::v2::Record represents a Sender ID ("spf2.0") record. Constructors The following constructors are provided: new(%options): returns Mail::SPF::v2::Record Creates a new Sender ID ("spf2.0") record object. %options is a list of key/value pairs representing any of the following options: text terms global_mods See "new" in Mail::SPF::Record. scopes Required. See "new" in Mail::SPF::Record. The 'mfrom' and 'pra' scopes are supported. There is no default. new_from_string($text, %options): returns Mail::SPF::v2::Record; throws Mail::SPF::ENothingToParse, Mail::SPF::EInvalidRecordVersion, Mail::SPF::ESyntaxError Creates a new Sender ID ("spf2.0") record object by parsing the string and any options given. Class methods The following class methods are provided: version_tag_pattern: returns Regexp Returns a regular expression that matches a version tag of 'spf2.0/' plus a comma-separated list of any of the 'mfrom' and 'pra' scopes. The following are valid version tags: spf2.0/mfrom spf2.0/pra spf2.0/mfrom,pra spf2.0/pra,mfrom default_qualifier results_by_qualifier See "Class methods" in Mail::SPF::Record. Instance methods The following instance methods are provided: text scopes terms global_mods global_mod stringify eval See "Instance methods" in Mail::SPF::Record. version_tag: returns string Returns 'spf2.0/' plus a comma-separated list of the scopes of the record. See "version_tag_pattern" for a list of possible return values. SEE ALSO
Mail::SPF, Mail::SPF::Record, Mail::SPF::Term, Mail::SPF::Mech, Mail::SPF::Mod <http://tools.ietf.org/html/rfc4408> For availability, support, and license information, see the README file included with Mail::SPF. AUTHORS
Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org> perl v5.18.2 2017-10-06 Mail::SPF::v2::Record(3)
All times are GMT -4. The time now is 09:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy