The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi All,
I am a real real beginner of Perl. I am trying to write a Perl Script to extract all the filenames with the date <FileName>.20041204****** in the given list of Filenames as below and place BSC, SBSCSubsystem and MCBTS filenames in separate files: -rw-rw-rw- 1 bsmbin bsmbin 0 Dec 3 00:31 arun2-20041127120100 -rw-rw-rw- 1 bsmbin bsmbin 0 Dec 3 00:31 abc2-20041127130812 -rw-rw-rw- 1 bsmbin bsmbin 0 Dec 3 00:31 abc1-20041127131046 -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 02:06 SBSCSubsystem-20041202143000 -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 02:06 SBSCSubsystem-20041202140000 -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 02:06 SBSCSubsystem-20041202133000 -rw-rw-rw- 1 bsmbin bsmbin 7018 Dec 3 02:06 MCBTSSubsystem-20041202143000 -rw-rw-rw- 1 bsmbin bsmbin 7019 Dec 3 02:06 MCBTSSubsystem-20041202140000 -rw-rw-rw- 1 bsmbin bsmbin 7020 Dec 3 02:06 MCBTSSubsystem-20041202133000 -rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202143000 -rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202140000 -rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202133000 -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 03:00 SBSCSubsystem-20041202150000 -rw-rw-rw- 1 bsmbin bsmbin 7020 Dec 3 03:00 MCBTSSubsystem-20041202150000 -rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 03:00 BSC-20041202150000 -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 04:00 SBSCSubsystem-20041202160000 -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 04:00SBSCSubsystem-20041202153000 The Algorithm I thought of is like this :- 1) Create 3 separate Files with names BSC, SBSCSubsystem and MCBTSSubsystem using File I/O. 2) First, check in the given list of filenames starting from the top, files with name BSC-20041202******. For each filename found/sorted out in this Format, move the corresponding filename to the File BSC.Continue this process, until you reach the end of the List. 3) Second, check in the given list of filenames starting from the top, files with name SBSCSubsystem- 20041202******. For each filename found/sorted out in this Format, move the corresponding filename to the File SBSCSubsystem. Continue this process, until you reach the end of the List. 4) Third, check in the given list of filenames starting from the top, files with name MCBTSSubsystem- 20041202******. For each filename found/sorted out in this Format, move the corresponding filename to the File MCBTSSubsystem. Continue this process, until you reach the end of the List. In this way, all the respective filenames are transferred to the corresponding Files. Think that Regular Expressions might be required to implement the Logic of File Sorting. Can anyone help me with a Perl Script for the same. Thanks,Kiran Considered: gregor42 - reap: dupliate of Sorting names using Regular Expressions and placing them in different Files.. Final vote: Keep = 5, Edit = 1, Reap = 20. In reply to Re^7: Sorting names using Regular Expressions and placing them in different Files.
by Kiran Kumar K V N
|
|