Sponsored Content
Top Forums Shell Programming and Scripting Split the file with renaming. Post 302757767 by Satish Shettar on Friday 18th of January 2013 02:42:04 AM
Old 01-18-2013
Split the file with renaming.

Hi Team,.

I am writing a script find the files which is not .gz format, split it into files which are 50000 line entries per file(using split -l 50000) then compress the smaller files using gzip and delete the original/big file.

After splitting it is creating the files in its own naming format where as I want to keep the same name with .seg1, .seg2, .seg3 so on.

I am not getting a hint to get the same naming with .seg*

could you help.

-rw-rw-r-- 1 scmpadm scmpuser 2390849170 Jan 15 10:58 activity.log.20130114
-rw-rw---- 1 scmpadm scmpuser 43977463 Jan 18 06:00 bgaa
-rw-rw---- 1 scmpadm scmpuser 44904640 Jan 18 06:04 bgab
-rw-rw---- 1 scmpadm scmpuser 48075578 Jan 18 06:07 bgac
-rw-rw---- 1 scmpadm scmpuser 50093878 Jan 18 06:09 bgad
-rw-rw---- 1 scmpadm scmpuser 51356468 Jan 18 06:14 bgae
-rw-rw---- 1 scmpadm scmpuser 49490389 Jan 18 06:20 bgaf
-rw-rw---- 1 scmpadm scmpuser 50395455 Jan 18 06:25 bgag
-rw-rw---- 1 scmpadm scmpuser 49959803 Jan 18 06:32 bgah
-rw-rw---- 1 scmpadm scmpuser 48350470 Jan 18 06:37 bgai
-rw-rw---- 1 scmpadm scmpuser 49689464 Jan 18 06:43 bgaj
-rw-rw---- 1 scmpadm scmpuser 38375424 Jan 18 06:45 bgak

activity.log.20130114
is the big file I wanted to get it as
activity.log.20130114.seg1.gz
activity.log.20130114.seg2.gz
activity.log.20130114.seg3.gz
activity.log.20130114.seg4.gz ....
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Split a file with no pattern -- Split, Csplit, Awk

I have gone through all the threads in the forum and tested out different things. I am trying to split a 3GB file into multiple files. Some files are even larger than this. For example: split -l 3000000 filename.txt This is very slow and it splits the file with 3 million records in each... (10 Replies)
Discussion started by: madhunk
10 Replies

2. Shell Programming and Scripting

Renaming a file

I am a complete Unix newbie and I need some help! (Please...) I need to rename a file from the following format: Test_Test_EAR_1234.ear To the following: Test_Test_EAR.ear In other words, I need to remove everything after & including the final underscore up to the "." What is the best... (6 Replies)
Discussion started by: VeloLisa
6 Replies

3. Shell Programming and Scripting

Renaming a file use another file as a sequence calling a shl

have this shl that will FTP a file from the a directory in windows to UNIX, It get the name of the file stored in this variable $UpLoadFileName then put in the local directory LocalDir="${MPATH}/xxxxx/dat_files" that part seems to be working, but then I need to take that file and rename, I am using... (3 Replies)
Discussion started by: rechever
3 Replies

4. Shell Programming and Scripting

File renaming from list of names contained in another file

I have to rename a large number of files so that the name of each file corresponds to a code number that is given side by side in a list (textfile). The list contains in column A the filename of the actual files to be renamed and in column B the name (a client code, 9 digits) that has to be... (7 Replies)
Discussion started by: netfreighter
7 Replies

5. Shell Programming and Scripting

renaming files using split with a delimiter

I have a directory of files that I need to rename by splitting the first and second halves of the filenames using the delimiter "-O" and then renaming with the second half first, followed by two underscores and then the first half. For example, natfinal1995annvol1_14.pdf -O filenum-20639 will be... (2 Replies)
Discussion started by: swimulator
2 Replies

6. Shell Programming and Scripting

Renaming file

Hello, I have an outstanding issue..Iam on linux and using a putty to connect to my server and then fire our unix shell script. At location /usr/sam a file called "er 1 32.txt" out boss transfer via application. From my end on terminal when i want to transfer this file to some other location... (2 Replies)
Discussion started by: j_panky
2 Replies

7. UNIX for Dummies Questions & Answers

Need help with Renaming a file

I have a file named as Pro_PatAct_MMDDYYYY.csv. I need to renmae it to this Pro_PatAct.csv without the date timestamp. Can someone help me to achieve this using a regular expn. (3 Replies)
Discussion started by: imran_affu
3 Replies

8. Shell Programming and Scripting

renaming the default output name of the split command

Hello, I would like to split a file but I dont what the subfiles to be named the way they are: ex: default name: xaa xab xac xad xae desired name: b01 b02 b03 b04 b05 I know I can rename them afterwards however I have a varialbe split lenghth, in other words I am not sure how... (2 Replies)
Discussion started by: smarones
2 Replies

9. UNIX for Dummies Questions & Answers

Renaming File

Hi there, I have 350 files in this directory: /home/adams/29 that was mistakenly renamed in this format: TTFILE_BIT_638478.txt.dat I want to take out the trailing .dat so that it ends in .txt: TTFILE_BIT_638478.txt I need help please. Thank you. (6 Replies)
Discussion started by: Creems
6 Replies

10. Shell Programming and Scripting

Renaming file and check for the renamed file existence

Hi Am trying to move a file from one name to another When I do "ls" to check for the moved filename I can see the file but when I try the same with a script am unable.. I think am doing some pretty silly error.. please help.. toMove=`ls | grep -E "partition.+"` mv $toMove partition._org... (7 Replies)
Discussion started by: Priya Amaresh
7 Replies
sa2(8)							    BSD System Manager's Manual 						    sa2(8)

NAME
sa2 -- Generate a system activity daily report file. SYNOPSIS
/usr/lib/sa/sa2 [-dgpu] [-n mode] [-e time] [-f filename] [-i seconds] [-s time] DESCRIPTION
The sa2 command is a shell script used to invoke the system activity reporter sar for purposes of generating the standard default daily report file. The report file generated is, /var/log/sa/sardd where the dd represents the current day of the month. The sa2 options are the same as those documented in sar(1). When sa2 runs, it will also remove data and report files, found in /var/log/sa, that are more than one week old. The sa2 command is intended to be started by cron. EXAMPLE CRON ENTRY
# Starting at 8am collect system activity records # every 20 minutes for 12 hours # 20 minutes = 1200 seconds # 12 hours with 3 samples each hour = 36 loops 0 8 * * 1-5 /usr/lib/sa/sa1 1200 36 # After the 12 hour period, # collect a system activity report 30 20 * * 1-5 /usr/lib/sa/sa2 -A FILES
/var/log/sa/sardd Default daily report file. /var/log/sa/sadd Default daily data file. dd are digits that represent the day of the month. SEE ALSO
sa1(8), sadc(8), sar(1), iostat(8), vm_stat(1), netstat(1), top(1), sc_usage(1), fs_usage(1), crontab(1), crontab(5) Mac OS X Jul 25 2003 Mac OS X
All times are GMT -4. The time now is 08:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy