The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Rename file based on first 3 characters of data in file jchappel UNIX for Dummies Questions & Answers 3 10-01-2008 03:21 PM
How to read and write directory or file contents in c++ ? namrata5 High Level Programming 3 09-28-2007 04:58 PM
read contents of a line sethunath UNIX for Dummies Questions & Answers 2 06-28-2007 01:51 PM
Creating file contents using contents of another file ReV Shell Programming and Scripting 21 02-24-2006 10:25 AM
Help with multiple file rename - change case of part of file name steve7 UNIX for Dummies Questions & Answers 7 06-30-2005 02:41 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-24-2009
Shark Tek Shark Tek is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 6
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..
 

Bookmarks

Tags
unix filename script rename

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0