hye there...
i have a problem to copy file in specific folder
that will change the name according to
host,time(%m%s) and date(%Y%M%D)
example folder name:
host_20100531.154101801
this folder name will always change...
but i just want to copy the AAA.txt and BBB.txt file..
this is some of the file that i will received.
10.0.1.79_20100601.085868276
10.0.1.79_20100601.090022717
10.0.1.79_20100601.090108699
10.0.1.79_20100601.090149586
but i will continuously get new file like above.
inside the directory i only have to copy two specific file.txt
the problem is i have to copy only the latest file.txt from the latest directory i received..
So, there is nothing like "latest file" i guess.
you have a file, named "file.txt" which is available in perhaps all the directory. and you want to copy "file.txt" from the latest directory.
one question,
10.0.1.79_20100601.085868276
The green part is millisecond or something?
ls -lrt 10.0.1.79*
Check if this gives you the latest directory ( which you want ) in the last.
if not, I think we need to sort the directories based on the date/time present in the directory name to get the latest directory.
sorry for not answering your question...
ls -lrt 10.0.1.79*this is the output:
10.0.1.79_20100601.090108699
total 24
10.0.1.79_20100601.090149586
total 24
10.0.1.79_20100601.090022717
total 27804
10.0.1.79_20100601.085868276
total 30740
i don't think the latest one is the last.
i think it based on the total.
---------- Post updated at 07:40 AM ---------- Previous update was at 07:30 AM ----------
the directory name is based on :
host +"_"+ Time.now.strftime(%Y%m%d.%M%S")+sprintf("%.5d",rand(100000))
ls -d 10.0.1.79* | sort -t"_" -nk2.1,2.4 -k2.5,2.6 -k2.7,2.8 -k2.10,2.11 -k2.12,2.13
yup this is works.
it display the latest directory.
ls -lrtd 10.0.1.79*
the output are:
10.0.1.79_20100601.090108699
10.0.1.79_20100601.090149586
10.0.1.79_20100601.090022717
10.0.1.79_20100601.085868276
thanks
---------- Post updated at 10:55 AM ---------- Previous update was at 10:51 AM ----------
i don't understand this:
-nk2.1,2.4 -k2.5,2.6 -k2.7,2.8 -k2.10,2.11 -k2.12,2.13
can you tell me what is this mean.
---------- Post updated at 11:50 AM ---------- Previous update was at 10:55 AM ----------
what should i do.
if i want to copy file.txt in the largest total mount of directory?