How to retain the header information of a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to retain the header information of a file
# 1  
Old 12-04-2007
How to retain the header information of a file

Hi,

I am using Bash shell to create some data and these data would be piped out to a file, let say output.txt.

This output.txt I would like to add some extra header information such as comments, descriptions and general information on the text.

I would like to know how could I maintain this type of information. I did try out using append to a file. In other word,I created a file with initial description and comments on it. Then, these data I would append (using << output.txt).

However, one limitation of this is that the data would be keep adding on top of the file each time repeated command are executed. Anyone have idea to solve this?

Besides, another problem is by having this header, I would like to further extract the data from the output.txt without the description and comments. I tried using head and tail but it doesnt work automatically. In other words, let say description and comment I have as first 5 lines of the output.txt. Currently I extract out these data using cat output.txt|..<all the operation>. But I could not help but extracting the first 5 lines as well.

Please advise. Appreciate alot.


Thanks.

-Jason
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies

2. Shell Programming and Scripting

awk to retain header lines in output

The awk below executes and produces the current output, which is correct, except I can not seem to include the header lines # and ## in the output as well. I tried adding !/^#/ thinking that it would skip the lines with # and output them but the entire file prints as is. Thank you :). file ... (8 Replies)
Discussion started by: cmccabe
8 Replies

3. UNIX for Dummies Questions & Answers

How can i sort a .txt file without loosing the header information?

Hi, I'm trying to sort 2 different .txt tab delimited files with the command line: sort -k 1b,1 inputfile > outputfile But doing that i'm also sorting the header (that ends at the end of my file). How can i sort a .txt file without sorting the header but conserving the header in the... (3 Replies)
Discussion started by: alisrpp
3 Replies

4. UNIX for Dummies Questions & Answers

cat to a file but retain header

Hi, Is there a way to write to a txt file each day but retain the header on the file? I'm cat'ing 5 files into one .txt file each day but I want the new data to be written after the first 2 lines which are: Progname Size Date Owner ---------------------------- Basically I want my new... (4 Replies)
Discussion started by: Grueben
4 Replies

5. Shell Programming and Scripting

Copying the Header & footer Information to the Outfile.

Hi I am writing a perl script which checks for the specific column values from a file and writes to the OUT file. So the feed file has a header information and footer information. I header information isaround107 lines i.e. Starts with START-OF-FILE ....... so on .... ... (11 Replies)
Discussion started by: filter
11 Replies

6. UNIX for Dummies Questions & Answers

Changing email header information by tweaking sendmail

How can i tweak sendmail configuration files so that the "Received:" field is removed from email header information? Or else can i change Received: (from enswitch@localhost) in email header to something likeReceived: (from xyz@localhost)? ---------- Post updated at 09:57 PM ---------- Previous... (2 Replies)
Discussion started by: proactiveaditya
2 Replies

7. Shell Programming and Scripting

retain last 1000 line in a file

I have large file with around 100k+ lines. I wanted to retain only the last 100 lines in that file. One way i thought was using tail -1000 filename > filename1 mv filename1 filename But there should be a better solution.. Is there a way I can use sed or any such command to change the... (9 Replies)
Discussion started by: nss280
9 Replies

8. Shell Programming and Scripting

Retain File Timestamp

There are directories of files that I have to run the dos2ux command on to get ride of the carriage return characters. Easy enough, but I have to retain the original timestamps on the files. I am thinking that I am going to have to strip off the timestamp for each file and convert it to unix time... (3 Replies)
Discussion started by: scotbuff
3 Replies

9. Shell Programming and Scripting

Retain file permissions when saving .sh file from internet [OS X]

Hello. I have written a bash script that I am sharing with an OS X community I am a member of. The purpose of the script is to execute a series of commands for members without them having to get involved with Terminal, as it can be daunting for those with no experience of it at all. I have renamed... (4 Replies)
Discussion started by: baza210
4 Replies

10. Linux

Reading the header of a tar file(posix header)

say i have these many file in a directory named exam. 1)/exam/newfolder/link.txt. 2)/exam/newfolder1/ and i create a tar say exam.tar well the problem is, when i read the tar file i dont find any metadata about the directories,as you cannot create a tar containig empty directories. on the... (2 Replies)
Discussion started by: Tanvirk
2 Replies
Login or Register to Ask a Question
VORBISCOMMENT(1)						   Vorbis Tools 						  VORBISCOMMENT(1)

NAME
vorbiscomment - edits Ogg Vorbis comments SYNOPSIS
vorbiscomment [-l] file.ogg vorbiscomment -a [ -t "tag=value" ] in.ogg out.ogg vorbiscomment -w in.ogg out.ogg DESCRIPTION
vorbiscomment reads, modifies, and appends Ogg Vorbis audio file metadata tags. OPTIONS
-a Append comments. -c commentfile Take comments from a file. The file is the same format as is output by the the -l option: one element per line in 'tag=value' for- mat. -h Show command help. -l List the comments in the ogg vorbis file. -q Quiet mode. No messages are displayed. -t 'tag=value' Specify a new tag on the command line. Each tag is given as a single string. The part before the '=' is treated as the tag name and the part after as the value. -w Replace comments with the new set given either on the command line with -t or from a file with -c. EXAMPLES
To just see what comment tags are in a file: vorbiscomment -l file.ogg To edit those comments: vorbiscomment -l file.ogg > file.txt [edit the comments in file.txt to your statisfaction] vorbiscomment -w -c file.txt file.ogg newfile.ogg To simply add a comment: vorbiscomment -a -t 'ARTIST=No One You Know' file.ogg newfile.ogg SEE ALSO
See http://xiph.org/ogg/vorbis/doc/v-comment.html for documentation on the Ogg Vorbis tag format, including a suggested list of canonical tag names. AUTHORS
Program Authors: Michael Smith <msmith@labyrinth.net.au> Ralph Giles <giles@xiph.org> Manpage Author: Christopher L Cheney <ccheney@debian.org> Xiph.org Foundation December 24, 2001 VORBISCOMMENT(1)