Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Grouping files on pattern

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 4 Weeks Ago   -   Original Discussion by gnnsprapa
gnnsprapa's Unix or Linux Image
gnnsprapa gnnsprapa is offline
Registered User
 
Join Date: Jul 2013
Last Activity: 14 November 2017, 4:46 AM EST
Posts: 39
Thanks: 2
Thanked 0 Times in 0 Posts
Hi Don Cragun,
My requirement is litle bit changed..instaed creating dynamic dir i want to send to these files to file list but not all files together rather first only one group set of files and then second group set.
So i am using this code

Code:
#!/bin/bash
cd /apps/sym/arcload/VSORT_X9/test
FILE_LIST=/apps/sym/arcload/VSORT_X9/SrcFiles/Source_input.txt
for file in *[_-]S[_-]*[_-]*[_-]*[_-][0-9][0-9][0-9][0-9][01][0-9][0-3][0-9][_-][0-2][0-9][0-6][0-9][0-6][0-9].txt
do      IFS='[_-]'
        set -- $file
        unset IFS
        echo "$file" >> $FILE_LIST
done

but here problem is its writing all files to the file list...i want to send first 4 grouped files do operation on that and same operation for next 2 grouped files and so on..

thanks for your help againLinux
Sponsored Links
    #9  
Old Unix and Linux 4 Weeks Ago   -   Original Discussion by gnnsprapa
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 14 December 2017, 12:36 AM EST
Location: San Jose, CA, USA
Posts: 10,774
Thanks: 590
Thanked 3,771 Times in 3,219 Posts
Quote:
Originally Posted by gnnsprapa View Post
Hi Don Cragun,
My requirement is litle bit changed..instaed creating dynamic dir i want to send to these files to file list but not all files together rather first only one group set of files and then second group set.
So i am using this code

Code:
#!/bin/bash
cd /apps/sym/arcload/VSORT_X9/test
FILE_LIST=/apps/sym/arcload/VSORT_X9/SrcFiles/Source_input.txt
for file in *[_-]S[_-]*[_-]*[_-]*[_-][0-9][0-9][0-9][0-9][01][0-9][0-3][0-9][_-][0-2][0-9][0-6][0-9][0-6][0-9].txt
do      IFS='[_-]'
        set -- $file
        unset IFS
        echo "$file" >> $FILE_LIST
done

but here problem is its writing all files to the file list...i want to send first 4 grouped files do operation on that and same operation for next 2 grouped files and so on..

thanks for your help againLinux
I do not understand what you are trying to do, so I don't see how I can help you.

You have removed all of the code that created groups of files, so I don't know what groups you are now talking about.

The code you have shown above could be replaced by the much simpler code:

Code:
#!/bin/bash
cd /apps/sym/arcload/VSORT_X9/test
FILE_LIST=/apps/sym/arcload/VSORT_X9/SrcFiles/Source_input.txt
printf '%s\n' > "$FILE_LIST"  *[_-]S[_-]*[_-]*[_-]*[_-][0-9][0-9][0-9][0-9][01][0-9][0-3][0-9][_-][0-2][0-9][0-6][0-9][0-6][0-9].txt

Please show us a brief list of filenames you want to process and then clearly explain how you decide which four files to process first, which two files to process next, and so on. And, clearly explain what operation you want to perform on each group of files.

Note that if the directories you created in your earlier problem are the groups you're talking about now, the list of files in your output file is not sorted into groups in any manner (and files that would have been grouped together in directories will not necessarily even be adjacent to each other in the output file produced by your code above).

More importantly, if you didn't understand the answers I provided in post #7 in this thread for your questions, please ask more questions. Our goal here is to help you learn how to write your own code. We are not here to act as your unpaid programming staff.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grouping log files based on counter manas_ranjan Shell Programming and Scripting 11 10-05-2012 12:26 PM
Grouping files according to certain fields in their name kristinu Shell Programming and Scripting 2 03-01-2012 11:30 AM
combine 3 files by grouping mykey242 Shell Programming and Scripting 4 04-22-2011 06:33 PM
parsing file names and then grouping similar files EAGL€ Shell Programming and Scripting 2 01-03-2010 10:54 PM
Grouping files into tars muay_tb Shell Programming and Scripting 3 03-27-2009 08:59 AM



All times are GMT -4. The time now is 04:12 AM.