Sponsored Content
Top Forums Shell Programming and Scripting Read File and use contents to rename another Post 302291084 by Shark Tek on Tuesday 24th of February 2009 04:06:40 PM
Old 02-24-2009
Read File and use contents to rename another

Hello guys, thank God that I found this forum.

I hope that someone can help me because I don't have any idea on how to start it. I know that for some of you this is a very simple task but I'm not as advance on shell scripting like many people out there.

I got this file with a permanent filename (RSA_RECORDS.txt) that the content always starts like this.

Code:
#  ISSUER CODE: QPPS                                                                                                                                                                                    
#  FROM DATE: 20090224                                                                                                                                                                                  
#  TO DATE: 00000000                                                                                                                                                                                    
#  SEQUENCE NUMBER: 001                                                                                                                                                                                 
#  RECORD COUNT: 0000000003                                                                                                                                                                             
#  NUMBER OF FIELDS: 015                                                                                                                                                                                
#  DELIMITER: ; 
BLABLABABLABLABLA
BLABLABABLABLABLA
BLABLABABLABLABLA

I need a shell script that can read those first four lines and creates a copy of that same file with the following name.

QPPS_20090224_00000000_01.txt

As you can notice the name is created by using those first four lines of the file.

<ISSUER CODE>_<FROM DATE>_<TO DATE>_<SEQUENCE NUMBER>.txt


The only issue here is that the main file changes everyday and that is the reason that I need a shell script that can dynamically create a copy of that main file with an specific name.

On my Unix server I can see that I have awk and sed support. No perl, python, ruby, etc.

Thanks for your help guys

Last edited by Shark Tek; 02-25-2009 at 01:23 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to read the contents of a file using PERL

Hi My requirement is to read the contents of a fixed length file and validate the same. But am not able to read the contents of the file and when i tried it to print i get <blank> as an output... I used the below satatements for printing the contents ... (3 Replies)
Discussion started by: meva
3 Replies

2. Shell Programming and Scripting

Read contents from a file

Hi Friends, I am new to this forum. Just struck up with a logic. I have a csv file seperated by ":" (colons). This csv file contains hostname and groups as follows: HOSTNAME:VT Group SGSGCT2AVPX001:Team1 SGSGCT2AVPX003:Team2 SGSGCT2AVPX005:Team2 PHMNCTTAVPX001:Team3 I want to... (2 Replies)
Discussion started by: dbashyam
2 Replies

3. Shell Programming and Scripting

How to read contents of a file into variable :(

My file is in this format : username : student information : default shell : student ID Eg : joeb:Joe Bennett:/bin/csh:1234 jerryd:Jerry Daniels:/bin/csh:2345 deaverm: Deaver Michelle:/bin/bash:4356 joseyg:Josey Guerra:/bin/bash:8767 michaelh:Michael Hall:/bin/ksh:1547 I have to... (1 Reply)
Discussion started by: dude_me5
1 Replies

4. Shell Programming and Scripting

how to read contents of file?

I have made a script something like this. I want it to read the contents of either file or directory but 'cat' and 'ls' is not working. Can anyone help me? I am a newbie in scripting so dont know much about it. I also dont know how can i put my code separatly on this forum #!/bin/bash echo... (9 Replies)
Discussion started by: nishrestha
9 Replies

5. Programming

read() contents from a file

Hi, I'm trying to implement a C program on ubuntu which reads the contents of a file that is passed in as an argument and then displays it to the screen. So far I've cobbled together this from bits online but most of it is probably wrong as its all copied and pasted... #include <stdio.h>... (2 Replies)
Discussion started by: cylus99
2 Replies

6. Shell Programming and Scripting

read contents of a file using AWK

Hi, I am kind of new at awk programming, so any help would be great ! I am trying to read a date from a file into a variable and a count into another variable and display both these variables. The file looks like the attached file... I tried this but it doesn't work ... ... (6 Replies)
Discussion started by: RDR
6 Replies

7. Shell Programming and Scripting

Replace partial contents of file with contents read from other file

Hi, I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file. i am able to... (2 Replies)
Discussion started by: seeki
2 Replies

8. Shell Programming and Scripting

How to read contents in each file and rename the file?

Hello All, Can you help me in writing a script for reading the specific position data in a file and if that data found in that file that particular file should be renamed. Ex: Folder : C:\\test and Filename : CLSACK_112214.txt,CLSACK_112314.txt,CLSACK_112414.txt Contents in the file would... (3 Replies)
Discussion started by: nanduedi
3 Replies

9. Shell Programming and Scripting

Remove or rename based on contents of file

I am trying to use the two files shown below to either remove or rename contents in one of those files. If in file1.txt $5 matches $5 of file2.txt and the value in $1 of file1.txt is not "No Match" then that value is substituted for all values in $5 and $1 of file2.txt. If however in $1 ... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. UNIX for Beginners Questions & Answers

Rename file in directory using contents within each file

In the below there are two generic .vcf files (genome.S1.vcf and genome.S2.vcf) in a directory. There wont always be two genaric files but I am trying to use bash to rename each of these generic files with specfic text (unique identifier) within in each .vcf. The text will always be different, but... (11 Replies)
Discussion started by: cmccabe
11 Replies
Boulder::Medline(3pm)					User Contributed Perl Documentation				     Boulder::Medline(3pm)

NAME
Boulder::Medline - Fetch Medline data records as parsed Boulder Stones SYNOPSIS
# parse a file of Medline records $ml = new Boulder::Medline(-accessor=>'File', -param => '/data/medline/medline.txt'); while (my $s = $ml->get) { print $s->Identifier; print $s->Abstract; } # parse flatfile yourself open (ML,"/data/medline/medline.txt"); local $/ = "*RECORD*"; while (<ML>) { my $s = Boulder::Medline->parse($_); # etc. } DESCRIPTION
Boulder::Medline provides retrieval and parsing services for Medline records Boulder::Medline provides retrieval and parsing services for NCBI Medline records. It returns Medline entries in Stone format, allowing easy access to the various fields and values. Boulder::Medline is a descendent of Boulder::Stream, and provides a stream-like interface to a series of Stone objects. Access to Medline is provided by one accessors, which give access to local Medline database. When you create a new Boulder::Medline stream, you provide the accessors, along with accessor-specific parameters that control what entries to fetch. The accessors is: File This provides access to local Medline entries by reading from a flat file. The stream will return a Stone corresponding to each of the entries in the file, starting from the top of the file and working downward. The parameter is the path to the local file. It is also possible to parse a single Medline entry from a text string stored in a scalar variable, returning a Stone object. Boulder::Medline methods This section lists the public methods that the Boulder::Medline class makes available. new() # Local fetch via File $ml=new Boulder::Medline(-accessor => 'File', -param => '/data/medline/medline.txt'); The new() method creates a new Boulder::Medline stream on the accessor provided. The only possible accessors is File. If successful, the method returns the stream object. Otherwise it returns undef. new() takes the following arguments: -accessor Name of the accessor to use -param Parameters to pass to the accessor Specify the accessor to use with the -accessor argument. If not specified, it defaults to File. -param is an accessor-specific argument. The possibilities is: For File, the -param argument must point to a string-valued scalar, which will be interpreted as the path to the file to read Medline entries from. get() The get() method is inherited from Boulder::Stream, and simply returns the next parsed Medline Stone, or undef if there is nothing more to fetch. It has the same semantics as the parent class, including the ability to restrict access to certain top-level tags. put() The put() method is inherited from the parent Boulder::Stream class, and will write the passed Stone to standard output in Boulder format. This means that it is currently not possible to write a Boulder::Medline object back into Medline flatfile form. OUTPUT TAGS
The tags returned by the parsing operation are taken from the MEDLARS definition file MEDDOC.DOC Top-Level Tags These are tags that appear at the top level of the parsed Medline entry. ABSTRACT ABSTRACT AUTHOR ADDRESS AUTHOR CALL NUMBER CAS REGISTRY/EC NUMBER CLASS UPDATE DATE COMMENTS COUNTRY DATE OF ENTRY DATE OF PUBLICATION ENGLISH ABSTRACT INDICATOR ENTRY MONTH GENE SYMBOL ID NUMBER INDEXING PRIORITY ISSN ISSUE/PART/SUPPLEMENT JOURNAL SUBSET JOURNAL TITLE CODE LANGUAGE LAST REVISION DATE MACHINE-READABLE IDENTIFIER MeSH HEADING NO-AUTHOR INDICATOR NOT FOR PUBLICATION NUMBER OF REFERENCES PAGINATION PERSONAL NAME AS SUBJECT PUBLICATION TYPE RECORD ORIGINATOR SECONDARY SOURCE ID SPECIAL LIST INDICATOR TITLE TITLE ABBREVIATION TRANSLITERATED/VERNACULAR TITLE UNIQUE IDENTIFIER VOLUME ISSUE Identifier The Medline identifier of this entry. Identifier is a single-value tag. Example: my $identifierNo = $s->Identifier; Title The Medline title for this entry. Example: my $titledef=$s->Title; SEE ALSO
Boulder, Boulder::Blast, Boulder::Genbank AUTHOR
Lincoln Stein <lstein@cshl.org>. Luca I.G. Toldo <luca.toldo@merck.de> Copyright (c) 1997 Lincoln D. Stein Copyright (c) 1999 Luca I.G. Toldo This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty. perl v5.10.1 2011-03-05 Boulder::Medline(3pm)
All times are GMT -4. The time now is 01:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy