Renumber position 88-94 inside all files matching criteria inside folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Renumber position 88-94 inside all files matching criteria inside folder
# 1  
Old 12-11-2012
Renumber position 88-94 inside all files matching criteria inside folder

There are 4 files inside one folder matching criteria i.e. File name = ABCJmdmfbsjopXXXXXXX_mm-dd-yyyy_XXX.data
Here is the Code which find the files matching criteria:-
Code:
TS=`date +"%m-%d-%Y"`| for fname in `find . -name "ABCJmdmfbsjop???????_${TS}*.data"`
do    # Matching File Processing Code.

Here is expected output:-
For each file with following file name pattern we need to look at position 1 inside first file matching our search criteria if first letter of the line is 5 then position 88-94 will be 0000001 then look for line immediately after 5 which starts with i.e. position 1 = 8 then position 88-94 will be 0000001 for that line starting with 8. Now again look first line start with 5, if matches then set position 88-94 will be 0000002. Now again look for line starting with 8 and set position 88-94 will be 0000002. Process this untill end of First file. Now assume last occurrence of line starting with 8 have position 88-94 = 0000010 then Look for occurrence of 5 in position 1 inside Second file If found then set position 88-94 will be 0000011, Also find line staring with 8 immediately and set position 88-94 will be 0000011.Continue numbering this until we are done with file matching our file search criteria.

File 1 name = ABCDEFG1234567_mm-dd-yy_hh_mm_ss123.data
Code:
Position:-      1234567890..............................................94
                101 101000048 CITY        ABCDEF FILE BC TOMJE                                    
                5220ABCDEF PQRSTUVWX   2342342345PPDAB            0000001
                101 101000048 CITY        ABCDEF FILE BC TOMJE        12
                8220000005005550001000000000000                   0000001
                5225ABCDEF PQRSTUVWX 121029080319303110           0000002 
                11 101000048 CITY        ABCDEF FILE BC TOMJE        13
                820000005005550001000000000000                    0000002 

File 2 name = ABCDEFG1234567_mm-dd-yy_hh_mm_ss145.data
Code:
Position:-      1234567890..............................................94
                101 101000048 CITY        ABCDEF FILE BC TOMJE                                    
                5220ABCDEF PQRSTUVWX   2342342345PPDAB            0000003
                101 101000048 CITY        ABCDEF FILE BC TOMJE        12
                8220000005005550001000000000000                   0000003
                5225ABCDEF PQRSTUVWX 121029080319303110           0000004 
                11 101000048 CITY        ABCDEF FILE BC TOMJE        13
                820000005005550001000000000000                    0000004 

File 3 name = ABCDEFG1234567_mm-dd-yy_hh_mm_ss167.data
Code:
Position:-      1234567890..............................................94
                101 101000048 CITY        ABCDEF FILE BC TOMJE                                    
                5220ABCDEF PQRSTUVWX   2342342345PPDAB            0000005
                101 101000048 CITY        ABCDEF FILE BC TOMJE        12
                8220000005005550001000000000000                   0000005
                5225ABCDEF PQRSTUVWX 121029080319303110           0000006 
                11 101000048 CITY        ABCDEF FILE BC TOMJE        13
                820000005005550001000000000000                    0000006 

File 4 name = ABCDEFG1234567_mm-dd-yy_hh_mm_ss189.data
Code:
Position:-      1234567890..............................................94
                101 101000048 CITY        ABCDEF FILE BC TOMJE                                    
                5220ABCDEF PQRSTUVWX   2342342345PPDAB            0000007
                101 101000048 CITY        ABCDEF FILE BC TOMJE        12
                8220000005005550001000000000000                   0000007
                5225ABCDEF PQRSTUVWX 121029080319303110           0000008 
                11 101000048 CITY        ABCDEF FILE BC TOMJE        13
                820000005005550001000000000000                    0000008

Thanks in Advance.
-Lance
# 2  
Old 12-11-2012
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to get all the files inside a folder then put the value in a variable?

Hi here is my code for i in `ls *.cmd` do msg aaa imp -U$AAAUSER -P$AAAUSERPWD <$i>>$curdir/import_tap.out -Jutf8 done I can only get all files with .cmd extension. what i need to get are all the files inside the specific folder Thanks (2 Replies)
Discussion started by: cmarzan
2 Replies

2. Shell Programming and Scripting

Selective position file editing inside folder

I need to process 4 files having name pattern as followis:- 1) Each file starts with = ABCJmdmfbsjop letters + 7 Digit Number _mm-dd-yyyy-hh-mm-ss-3 Digit Number.data where ABCJmdmfbsjop :- is alphabet. Each file starts with this ABCJmdmfbsjop alphabet. 7 Digit Number :- Numeric 7 digits. __:-... (1 Reply)
Discussion started by: lancesunny
1 Replies

3. UNIX for Dummies Questions & Answers

How to fetch files right below based on some matching criteria?

I have a requirement where in i need to select records right below the search criteria qwertykeyboard white 10 20 30 30 40 50 60 70 80 qwertykeyboard black 40 50 60 70 90 100 qwertykeyboard and white are headers separated by a tab. when i execute my script..i would be searching... (4 Replies)
Discussion started by: vinnu10
4 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Touch 10% of the total files inside a folder

I'm trying to make this code below to work but I can't find the way to do the following: I want to make the script to touch only 10% of the total amount of files counted inside the given directory instead of all like it is now. I would greatly appreciate it if someone can give me a direction on... (9 Replies)
Discussion started by: regraphix
9 Replies

5. Shell Programming and Scripting

matching patterns inside a condition in awk

I have the following in an awk script. I want to do them on condition that: fext == "xt" FNR == NR { />/ && idx = ++i $2 || val = $1 next } FNR in idx { v = val] } { !/>/ && srdist = abs($1 - v) } />/ || NF == 2 && srdist < dsrmx {... (1 Reply)
Discussion started by: kristinu
1 Replies

6. Shell Programming and Scripting

Help with matching pattern inside a file

I have a huge file that has roughly 30304 lines. I need to extract specific info from that file. For example, Box 1 > *aaaaaaaajjjj* > hbbvjvj > jdnnfddllll > *dgdfhfekwjh* Box 2 > *aaaaaaa'aj'jjj* > dse hkjuejef bfdw > dyeee > dsewq > *dgdfhfekwjh* >feweiuei Box 3 > *aaaa"aaaaj"jjj* >... (25 Replies)
Discussion started by: Ernst
25 Replies

7. Shell Programming and Scripting

Last modified time of the folder is changing when I view the file inside the directory

Hi., Last modified time of the folder is changing when I view the file inside the directory. Here is the test on sample directory. I believe that ls -l commands gives the time detail w.r.t last modified time. Pl. suggest. bash-3.2$ mkdir test bash-3.2$ cd test bash-3.2$ touch myfile.txt... (2 Replies)
Discussion started by: IND123
2 Replies

8. Shell Programming and Scripting

Security for applets files inside a folder

Friends I have a directory structure /a/b/c/applets/ This directory has .java, .class and other applet files. I gave the applets folder 755 permission because these applets are displayed at different web pages of a portal. Now I want to restrict the visibility of all the files in this... (0 Replies)
Discussion started by: dahlia84
0 Replies

9. Shell Programming and Scripting

Matching using Regex inside a file

I need scan through some files, then open the file one by one and scan inside the file using perl to see if it contain a start tag and end tag which the end tag is the mirror image of the start tag, the start tag and end tag only have 5 char. And inside the file there is "http://". It is just a... (5 Replies)
Discussion started by: blueblur
5 Replies

10. Shell Programming and Scripting

looping a array inside inside ssh is not working, pls help

set -A arr a1 a2 a3 a4 # START ssh -xq $Server1 -l $Username /usr/bin/ksh <<-EOS integer j=0 for loop in ${arr} do printf "array - ${arr}\n" (( j = j + 1 )) j=`expr j+1` done EOS # END ========= this is not giving me correct output. I... (5 Replies)
Discussion started by: reldb
5 Replies
Login or Register to Ask a Question