Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Copy all the files with time stamp and remove header,trailer from file Post 302128278 by ksrams on Monday 23rd of July 2007 09:21:37 PM
Old 07-23-2007
Thanks for quick reply Shell_Life.
Quote:
Originally Posted by Shell_Life
Ksrams,
Please give us more information, such as sample of file name with the
timestamp and the expected output.
Here is the info.
Input file(s) located under directory /input and file names are:
1) input1_20070723_171556.txt
2) input2_20070723_171556.txt
3) input3_20070723-171556.txt
input1_20070723_171556.txt sample data:

HEADERRECORD 20070723 DESC
aaa 111 222 333 bbb
bbb 222 111 444 ccc
ccc 333 444 111 ddd
TRAILERRECORD 3


I want the do the following process in one script..
a) First thing is i want to copy all the files into /ouput directory
b) rename the files under /out directory to
1) rename input1_20070723_171557.txt file to input1.txt and also remove HEADERRECORD 20070723 DESC(header record i.e always first line) and TRAILERRECORD 3(Detail record i.e always last line in file) from input1.txt
input1.txt file data should be:

aaa 111 222 333 bbb
bbb 222 111 444 ccc
ccc 333 444 111 ddd


2) rename input2_20070723_171557.txt to input2.txt and also remove first and last lines from input2.txt
3) rename input3_20070723_171556.txt to input3.txt and also remove first and last lines from input3.txt

I hope this is much better compare to my previous post.
I would appreciate if you guide me on this..

Thanks in advance..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove header(first line) and trailer(last line) in ANY given file

Hi, I need some help in removing the header (first line) and the trailer (last line) in a give file... The data file actually comes in EBCDIC format and I converted it into ASCII.. Now I need to strip off the first line and the last line.. I think we can use sed to do something like this:... (2 Replies)
Discussion started by: madhunk
2 Replies

2. Shell Programming and Scripting

Merge text files while combining the multiple header/trailer records into one each.

Situation: Our system currently executes a job (COBOL Program) that generates an interface file to be sent to one of our vendors. Because this system processes information for over 100,000 employees/retirees (and growing), we'd like to multi-thread the job into processing-groups in order to... (4 Replies)
Discussion started by: oordonez
4 Replies

3. Shell Programming and Scripting

how to copy an alertlog file from a particular time stamp?

Hi, Can any one tell me how to copy an alertlog file from a particular time stamp using shell script? Thanks (3 Replies)
Discussion started by: suman_dba1
3 Replies

4. Shell Programming and Scripting

improve performance - replace $\| with $#@ and remove header and trailer records

Hi All, In my file i need to remove header and trailer records which comes in 1st line and last line respectively. After that i need to replace '$\|' with '$#@'. I am using sed command for this and its taking lot of time. Is there any other command which can be used to improve performance? ... (1 Reply)
Discussion started by: HemaV
1 Replies

5. Shell Programming and Scripting

Identify log files based on time stamp,zip and then copy..HELP

Hi All, PFB is a requirement. I am new to shell scripting. So plz help. It would be highly appreciated. 1. choose all the log files based on a particular date (files location is '/test/domain')--i.e,we should choose all the files that are modified on 29th November, neither 28th nor 30th 2.... (3 Replies)
Discussion started by: skdas_niladri
3 Replies

6. UNIX for Dummies Questions & Answers

Adding header and trailer into a file

Hi, I want to add the below Header to all the files in sequence File1,File2,File3...etc "ABC,<number of chracter in the file>" e,g - If File1 is as below pqrstuvdt abcdefgh then I want to add the above header into it ,So that File1 becomes as below ABC,17 pqrstuvdt abcdefgh ... (9 Replies)
Discussion started by: spari2
9 Replies

7. Shell Programming and Scripting

Remove last few characters in a file but keeping Header and trailer intact

Hi All, I am trying write a simple command using AWK and SED to this but without any success. Here is what I am using: head -1 test1.txt>test2.txt|sed '1d;$d' test1.txt|awk '{print substr($0,0,(length($0)-2))}' >>test2.txt|tail -1 test1.txt>>test2.txt Input: Header 1234567 abcdefgh... (2 Replies)
Discussion started by: nvuradi
2 Replies

8. Shell Programming and Scripting

Script to validate file header and trailer

Hi, I need a script that validates a file header/detail/trailer. File layout is: Header - Rec_Type|File_name|File_Date Detail - Rec_Type|field1|field2|field3... Trailder - Rec_Type|File_name|File_Date|Record_count Sample Data: HDR|customer_data.dat|20120709... (7 Replies)
Discussion started by: ash_sh
7 Replies

9. Shell Programming and Scripting

Verify the header and trailer in file

please see my requirement, I hope I am clear. (9 Replies)
Discussion started by: mirwasim
9 Replies

10. UNIX for Beginners Questions & Answers

Append pipe | at the end of all the rows except header n trailer for all the files under a directory

Hi Experts Need help... I am looking for a Unix script to append pipe | at the end of all the rows (except header and trailer)in all the files placed under the directory /interfaces/Temp e.g. Header row1 row2 row3 Trailer The script should read all the files under... (3 Replies)
Discussion started by: phani333
3 Replies
NCOPY(1)							       ncopy								  NCOPY(1)

NAME
ncopy - NetWare file copy SYNOPSIS
ncopy -V ncopy [ -vmMnpptu ] [ -s amount ] file destinationfile|directory ncopy [ -vmMnpptu ] [ -s amount ] file1 [ file2 ... ] directory ncopy -r [ -vmMnpptu ] [ -s amount ] srcdir dstdir DESCRIPTION
With ncopy you can copy files to different locations on a single NetWare file server without generating excess network traffic. The pro- gram uses a NetWare function to do the copy rather than transferring the file across the network for both the read and write. If the last argument is a directory, ncopy will copy the source file(s) into the directory. If only two files are given and the last argu- ment is not a directory, it will copy the source file to the destination file. If the source and destination files are not on the same NetWare server (or are not on NetWare servers at all), ncopy will do a normal file copy. OPTIONS
-V Show version number and exit -v Verbose copy. Will show current file and percentage completion. -m Copy MAC resource fork. Copies MAC resource fork together with data fork. -M Copy MAC resource fork to/from non-MAC filesystem. It expects/creates resource forks in subdirectory .rsrc of each directory copied. If you want to copy files from MAC volume to .rsrc scheme, you must specify both options, -mM. It is not possible to create .rsrc direc- tory on MAC-aware volume in one step, you must first copy data to non-MAC media using ncopy -mM and then copy them back using ncopy -M. If you want to copy files from .rsrc scheme on MAC volume to real MAC multiple-forks file, you must first copy data to non-MAC filesys- tem using ncopy -M and then copy them back using ncopy -mM. -n Nice NetWare copy. Will sleep for a second between copying blocks on the NetWare server. Gives other people a chance to do some work on the NetWare server when you are copying large files. This has no effect if you are not copying on a NetWare server. -s amount Nice time slice factor. Used in conjunction with the -n option, this specifies the number of 100K blocks to copy before sleeping. Default is 10. (1 Megabyte) -p Preserve file attributes and date/time during copy. -pp Preserve file attributes, date/time and owner during copy. Name of owner is preserved, not owner ID. -t Preserve trustees during copy. Trustee name is preserved, not ID. -r Perform recursive copy. -u Perform copy only if mtime or size differs. BUGS
ncopy does not preserve long (MAC, NFS, FTAM, OS2) names during copy. SEE ALSO
ncpmount(8), ncpumount(8) CREDITS
ncopy was written by Brian G. Reid (breid@tim.com) and Tom C. Henderson (thenderson@tim.com). Many thanks to Volker Lendecke (lendecke@math.uni-goettingen.de) for the ncpfs and ncplib which made ncopy possible. Some further work was done by Petr Vandrovec (van- drove@vc.cvut.cz). ncopy 17/03/1996 NCOPY(1)
All times are GMT -4. The time now is 06:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy