Shell script to find files

January 19, 2011 at 16:24:46
Specs: Linux
I'm trying to write a script to find files in a directory that have timestamps(YYYYDDMMThh:mm:ss) in the file name that are within a second of each other and then append them.
How do I go about doing this.
Thanks,
vstl

See More: Shell script to find files

Report •

#1
January 21, 2011 at 18:03:49
PM a guy named nails. He does this in his sleep.

Why did it take me over a year to phone in a problem to ATT?


Report •

#2
January 24, 2011 at 14:39:56
Sorry, I'm new to this forum. Where do I PM for nails?
Thanks,
vstl

Report •

#3
January 24, 2011 at 22:37:23
You do not have to PM me. I am here. What you are asking for is a lot of work. This includes finding the files, parsing the file names, and doing arithmetich on the minitues and seconds. This involves more work than I have time for.

I will get you started. This stub finds all files in the current directory that start with 20. I use the set command to parse the file name into 3 different strings where the 2nd and 3rd strings are the minute and second respectively:


#!/bin/bash

find . -type f -name "20*"   -print|while read file
do
   set - $(IFS=":"; echo $file)
   echo $1
   echo $2  # minutes
   echo $3  # seconds
done

If you have any further questions, I'll try to answer them, but you are going to have to take it from here.


Report •

Related Solutions

#4
January 25, 2011 at 08:35:58
Thanks for the help. I'll see how far I can go, and let you know if I have questions.
vstl

Report •

Ask Question