What's UNIX Expert's suggestion for this thread ?

Assume that 100 file's of type .txt are saved in directory
in which,

40 .txt files having ID 225 in column x
10 .txt files having ID 220 in column x
30 .txt files having ID 115 in column x
and remaining 20 .txt file's having UNIQUE ID say 226,227,228,229,230....

first I want to read only files with UNIQUE ID
like this

for file  in *.txt of UNIQUE ID; do
go_function_abc;
done

after this I want to read file's having ID 225

for file in *.txt of ID 225; do
execute_this_function_only_once; (this has to be executed only once I mean when $file==1,not 40 times)
go_to_function_xyz;(this has to be executed 1 to 39 times, that is filecount<no of files)
go_to_last_function(execute this function when filecount==No of files, thats 40==40)
then file's with ID 220,115...

Here for me, no problem in running file's with UNIQUE ID, if many file's are having same ID, then this is the only solution left to me

I hope UNIX Expert's will have solution for this.

Sounds like an interesting problem.

But it might help to have some sample input. It would give a better idea what you mean by "column x".

And maybe a more descriptive title than "unix expert's suggestion" might be a good idea. That would be up to a moderator.

Column X is containing ID, to indicate it is same for all files I mentioned X it's column 14

Not clear. Is the column in the file name or in the file itself?

And, function_abc is the same all over, or does it change with the file in use?

Meanwhile you should know that it helps tremendously to post sensible sample data.

Dear Sir, column is in file and function abc is only for file with unique ID

and for file's with same ID, there are 3 function,

  1. 1st function should be executed only once that is at starting(don't repeat)
  2. 2nd function should be executed till filecount <no of files(repeat)
  3. 3rd function should be executed when filecount==no of files(don't repeat)

Here's your (bash!) solution:

for file in *.txt; do read <"$file"; Ar=( "$REPLY" ); echo mv "$file" "$file.${Ar[1]}mod"; done

execute_this_function_only_once;  
for file in *.225mod; do go_to_function_xyz; mv "$file" "${file%.*}"; done
go_to_last_function

... same for 220, 115, ...

for file in *mod; do go_to_function_abc; mv "$file" "${file%.*}"; done 
1 Like

Thank you , you mean manually we need to enter for *.225 .....;done

Sorry, I don't understand your question. You said you have three common IDs, and the rest unique IDs. So what is expected?
Again: for vague requirements/specifications you can expect vague hints/proposals only...

Dear Sir here requirement is like this

  1. store all file's in one array
  2. compare $8 1st field with $8 1st field of other file, if not matching, then that filename should be moved to UNIQUE ID array(delete from main array), if suppose matched then ID is duplicate so duplicate ID should be stored in new array, there can be any number of duplicate ID's

after this I want to access Unique ID file's first
some function
once above 1 completes

then 1st duplicate ID file's array
some function

then 2nd duplicate ID file's in array

3rd duplicate ID file's

4th duplicate ID file's

input file1

23-Oct-1985    05:36:00    PM    14.982    88.008    255    15    91
23-Oct-1985    05:36:00    PM    14.982    88.008    260    14.9    91
23-Oct-1985    05:36:00    PM    14.982    88.008    265    14.8    91
23-Oct-1985    05:36:00    PM    14.982    88.008    270    14.6    91
23-Oct-1985    05:36:00    PM    14.982    88.008    275    14.5    91
24-Oct-1985    06:17:00    AM    14    88    0    29.2    108
file 2
24-Oct-1985    06:17:00    AM    14    88    5    29.2    108
24-Oct-1985    06:17:00    AM    14    88    10    29.1    108
24-Oct-1985    06:17:00    AM    14    88    15    29    108
24-Oct-1985    06:17:00    AM    14    88    20    29    108
24-Oct-1985    06:17:00    AM    14    88    25    29    108

file3

08-Dec-1983    10:28:00    AM    17    84    245    12    50
08-Dec-1983    10:28:00    AM    17    84    250    11.9    50
08-Dec-1983    10:28:00    AM    17    84    255    11.8    50
08-Dec-1983    10:28:00    AM    17    84    260    11.7    50
08-Dec-1983    10:28:00    AM    17    84    265    11.6    50
08-Dec-1983    10:28:00    AM    17    84    270    11.5    50
08-Dec-1983    10:28:00    AM    17    84    275    11.5    50

file 4

03-Oct-1985    03:00:00    AM    16.183    83.483    0    29.1    50
03-Oct-1985    03:00:00    AM    16.183    83.483    5    29.1    50
03-Oct-1985    03:00:00    AM    16.183    83.483    10    29.1    50
03-Oct-1985    03:00:00    AM    16.183    83.483    15    29.4    50
03-Oct-1985    03:00:00    AM    16.183    83.483    20    29.3    50
03-Oct-1985    03:00:00    AM    16.183    83.483    25    29.2    50
03-Oct-1985    03:00:00    AM    16.183    83.483    30    29    50