Appending sequence number at the end of file name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Appending sequence number at the end of file name
# 1  
Old 09-02-2015
Appending sequence number at the end of file name

hi team,

i need a script for renaming a file with sequence number. script get a file from one directory'
Code:
/home/billing/Cmm/sms/sms_tmp

' append sequence no at the end of file name and move a file to other directory
Code:
/home/billing/Cmm/sms/

.
actual file is
Code:
cdr201508271527

file after renaming
Code:
cdr201508271527_00001

. script also have capability to save the state of sequence number so when next time it will increment it will start increment from the last file transferred. i have a multiple files in /home/billing/Cmm/sms/sms_tmp . each file can be identify with time stamp.

Last edited by mfaizan40; 09-03-2015 at 02:49 AM.. Reason: code tags
# 2  
Old 09-02-2015
What have you tried so far?
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 09-02-2015
On top of answering jim mcnamara's question, you should consider supplying more details, e.g. is it one file, multiple or all files in the source directory, and how to discriminate between them, and based on which criteria the sequence numbers should be distributed.
This User Gave Thanks to RudiC For This Post:
# 4  
Old 09-02-2015
After telling us what you tried so far yu might also want to tell us what your problem is. So far you haven't asked anything specific. You do know there is a mv command to move and rename files, yes?

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with appending random sequence to huge CDR file

Hi, I am in a terrible emergency. I have multiple cdr files with line count >6000. I need to append |0| | | | | | | |random| to end of each line. The random number should never repeat. Please help with a shell script to process all cdr's in a directory with above requirement. (23 Replies)
Discussion started by: shiburnair
23 Replies

2. Shell Programming and Scripting

Appending newline character End of File

Hi Gurus, Need help. I'm a beginner in Unix. I have a requirement, need to add or append newline (\n) character in file. Sample Data: 1|Main|Test|~# 2|Main|Hello|~# 3|Main|Unix|~# 4|Main|File|~#Output: 1|Main|Test|~# 2|Main|Hello|~# 3|Main|Unix|~# 4|Main|File|~#\n -- append only... (13 Replies)
Discussion started by: Gouri Solleti
13 Replies

3. UNIX for Advanced & Expert Users

Appending a files contents to the end of a specific file name in several directories

Here is my dir structure: /tmp/dave/myappend.txt /tmp/dave/dir1/test.txt /tmp/dave/dir2/test.txt /tmp/dave/dir3/test.txt /tmp/dave/dir4/test.txt I want to append the contents of myappend.txt to the end of each file with the name "test.txt" in all dirs in /tmp/dave/ I have tried this:... (2 Replies)
Discussion started by: bigd213
2 Replies

4. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

5. UNIX for Dummies Questions & Answers

Appending Date at the end ONLY in first line of file

Hi, My requirement is to append a date in format DDMMYYYYHHMISS at the end of first line of file which is HEADER. I am trying command sed -i '1s/.*/&<date_format>/' <file_name> Where <date_format>=`date +%m%d%Y%H%M%S` I am somehow misisng the right quotes ti get this added in above... (2 Replies)
Discussion started by: sanjaydubey2006
2 Replies

6. UNIX for Dummies Questions & Answers

Adding a running sequence number while appending 2 files

Hi, I have to append 2 files and while appending i need to add a running sequence number (counter ) for each line at the first column. For e.g. If file x contains details as below. Tom Dick Harry Charlie and file y contains Boston Newyork LA Toledo Then the new file should... (1 Reply)
Discussion started by: kalyansid
1 Replies

7. UNIX for Dummies Questions & Answers

Adding Sequence Number to file

Hi All, I need to create a script which checks for a particular file for eg.kumar1.txt. If kumar1.txt is already exist the script should increment the file name as kumar2.txt and so on. Please Advise. Thanks & Regards, Kumar66 (2 Replies)
Discussion started by: kumar66
2 Replies

8. Shell Programming and Scripting

Appending a new field at the end in a file

can anyone tell me please ......how to append a new field at the end of a file with the help of sed or some other command in bourne shell (8 Replies)
Discussion started by: amitpta
8 Replies

9. Shell Programming and Scripting

Appending string at the end of the file

Hello, I wanted to append 'XYZ' at the end of the text file. How can i do this? I searched the forums and i am not getting what i want. Any help is highly appreciated. Thanks (2 Replies)
Discussion started by: govindts
2 Replies

10. Shell Programming and Scripting

appending date at the end of the file

I have file called xx Now i want to rename this file as xxYYYYMMDD_HHMIAM.xls Here is my code.. export DATE1=`date +%Y%m%d` mv xx xx$DATE1 This code renames as xxYYYYMMDD Now how can i append HHMIAM at the end of the file? Any help is appreciated... (3 Replies)
Discussion started by: govindts
3 Replies
Login or Register to Ask a Question