Seperate FlatFiles and append date !


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Seperate FlatFiles and append date !
# 1  
Old 10-11-2010
Seperate FlatFiles and append date !

Hi everyone,

I need to create a script which dynamically splits Flatfiles and append a date. Only those should be splitted if they have more than a million rows but the date should be append every time.

E.g. in my folder I have 3 flat files and only 1 of them has more than a million rows.

FileX.out
FileY.out
FileZ.out

They should look like this now-->

FileX.out001_ddmmyy
FileX.out002_ddmmyy
FileY.out_ddmmyy
FileZ.out_ddmmyy

Can anyone help me on this?

Thanks in advance
Regards Richard
# 2  
Old 10-11-2010
have a look at split command.

and to get date use

Code:
#  date +%d%m%y
111010

Though it would likely be better to use year-month-day as this will make life easier for sorting later:

#  date +%Y%m%d
20101011

:-)

# 3  
Old 10-11-2010
thank you for your post.

and it works good.

But how does this will look in a ksh? and how can he split and add the date dynamically?

FileX.out
FileY.out
FileZ.out

are always created in this format, and in the end only the new format (prefix 001 002_date) should be visible
# 4  
Old 10-11-2010
Try:
Code:
for i in file*.out
do
  mv "$i" "${i}_$(date +%d%m%y)"
done

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append date to an executing script

This works except the date being sent to this script. Is it because I am trying to write to an executing script? Is there a better way? date '+%m-%d-%Y_%I:%M-%p'>> Send_Email.sh CONTENT="Backup to Maxtor Drive has occured." echo "Sending email." /usr/sbin/ssmtp -t << EOF To:... (1 Reply)
Discussion started by: drew77
1 Replies

2. Programming

Date format change from mm/dd/yyyy to yyyymmdd in comma seperate line in perl

Hi All, I have line ,A,FDRM0002,12/21/2017,,0.961751583,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, it contains date in mm/dd/yyyy format i want to change this to yyyymmdd format using perl. Use code tags, thanks. (8 Replies)
Discussion started by: vishal0746
8 Replies

3. Shell Programming and Scripting

How to append date to filename, but base it on yesterday's date?

Hello, I'd like to write a monthly archive script that archives some logs. But I'd like to do it based on yesterday's date. In other words, I'd like to schedule the script to run on the 1st day of each month, but have the archive filename include the previous month instead. Here's what I... (5 Replies)
Discussion started by: nbsparks
5 Replies

4. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

5. UNIX for Dummies Questions & Answers

append file name with date

Hi guys, I created a very basic script that moves a specified file to a directory that I have set using the mv command. What I would like to do is append the file name with the date and time. So if I was to use the script to move a file called abc.txt, the script should rename the file... (1 Reply)
Discussion started by: jjc
1 Replies

6. UNIX for Dummies Questions & Answers

How To Append Date to File Name - AIX 5.3

Hello, I am a novice user on an AIX 5.3 system. I am running some scripts via crontab and redirecting the output to a file. For example: /home/cognos/ppdev_refresh.sh > /home/cognos/ppdev_refresh.txt I want to append the system date to the file name so it becomes:... (7 Replies)
Discussion started by: Maurice Frank
7 Replies

7. Shell Programming and Scripting

MV all files and append date

All, I am trying to setup a command that will mv all files in a directory to another location and append a filedate. for example: mv * /location/*'date %y%m%d' Any help? (2 Replies)
Discussion started by: markdjones82
2 Replies

8. Shell Programming and Scripting

append date to file

Hi I need to append date to filename.Wrote script to get the date from table ,take this date filed and append to my i/p file when call the below script.Any help should be appreciated . Exampel If call the below script a4.sh filename o/p should be filename.2008-02-29 .... (6 Replies)
Discussion started by: mohan705
6 Replies

9. Shell Programming and Scripting

Append date to a file from CRON

Hi, I am trying to append date in DAY_Mon_dd_yyyy at the end of a filename from cron. Cron entry looks as below. (script to execute) > test_file_`date +"a_%b_%d_%Y"` File name created after executing the job is test_file_ I am expecting the filename to be something like ... (8 Replies)
Discussion started by: dncs
8 Replies

10. UNIX for Dummies Questions & Answers

Append date to filename

What is the easiest way to append the date (year, month, day) to a filename? (5 Replies)
Discussion started by: hshapiro
5 Replies
Login or Register to Ask a Question