How to copy specific file.txt in specific folder?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to copy specific file.txt in specific folder?
# 8  
Old 05-31-2010
yup...
sori for the mistake...
its latest folder...
# 9  
Old 05-31-2010
Code:
 touch -t $(date +%Y%m%d%H%M) tmpfile
 mydir=$( (find . -name "host_????????.?????????*" -type d -newer tmpfile) )

if [$? -ne 0 ] ; then

 cp AAA.txt BBB.txt $mydir
fi

mydir=$( (ls -1dt host_????????.????????? | head -n 1) )
cp AAA.txt BBB.txt $mydir


Last edited by ygemici; 05-31-2010 at 05:19 PM.. Reason: add lines for solution
# 10  
Old 05-31-2010
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..

need ur help ASAP Smilie
# 11  
Old 05-31-2010
Please, excuse the interruption. I'm trying to follow this thread, but really I have no idea what you are asking for.

These are files, or directories?:
Code:
10.0.1.79_20100601.085868276
10.0.1.79_20100601.090022717 
10.0.1.79_20100601.090108699 
10.0.1.79_20100601.090149586

This suggests they are files:
Quote:
but i will continuously get new file like above.
So what does this mean:
Quote:
inside the directory i only have to copy two specific file.txt
What directory?

And this:
Quote:
the problem is i have to copy only the latest file.txt from the latest directory i received..
What are the files here? What are the directories?

Maybe you should try to start again, from the beginning - slowly, and more clearly, because this is really going nowhere, sadly.
# 12  
Old 05-31-2010
sorry for making you confused.

1)these are the directories:
10.0.1.79_20100601.085868276
10.0.1.79_20100601.090022717
10.0.1.79_20100601.090108699
10.0.1.79_20100601.090149586

2)yup i will continuously get new directory like above
but the directory name according to time and date that they are created.

3)inside these the latest directory that have been created.
can you get what i mean.
if not please ask me.
sorry for that.
and thanks for the reply...
# 13  
Old 06-01-2010
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,
Code:
10.0.1.79_20100601.085868276

The green part is millisecond or something?


Code:
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.
# 14  
Old 06-02-2010
yup...
you are right...Smilie

but then i do not sure whether
10.0.1.79_20100601.085868276green part is millisecond or not.

i want it based on time and date.
thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Searching for file types by count in specific folder in RHEL 6

So I'm trying to search for the top 10 or 15 items under a directory by file type. I want to run a command on a directory and get something like the following: Example of expected output.. .PDF: 100, .txt: 95, .word: 80.. What would be the best way of going about this? I've searched around... (2 Replies)
Discussion started by: shackle101
2 Replies

2. Shell Programming and Scripting

Find and Copy file of specific location

Dear All, I need to transfer all files present in one location to another but those files should be of specific extension like. Find and copy all files of extension .xls, .pdf, .txt from location usr/tmp to location /per/Treat (6 Replies)
Discussion started by: yadavricky
6 Replies

3. Shell Programming and Scripting

Copy specific file (different but same name) as folder name

I have to copy a particular file present in a main folder having part of the file-name present in many sub-folders to a new destination preserving the name of the source "part of the main folder" and previous file-name of the output file: Example: From /005_0/1000/005.xxx ->... (7 Replies)
Discussion started by: wappor
7 Replies

4. Homework & Coursework Questions

Shell Scripting , Moving Old file to specific folder

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: There are files stored like 14.Aug.2014.log, 15.Aug.2014.log etc. in a folder $HOME/log you need to find out all... (4 Replies)
Discussion started by: shajoftaj
4 Replies

5. Ubuntu

Shell Scripting , Moving Old file to specific folder

There are files stored like 14.Aug.2014.log, 15.Aug.2014.log etc. in a folder $HOME/logyou need to find out all the log files of last 1 month and move them into $HOME/logs/lastmonth/ this should be implemented with reference of file name. ---------- Post updated at 12:30 PM ----------... (3 Replies)
Discussion started by: shajoftaj
3 Replies

6. Shell Programming and Scripting

Delete specific parts in a .txt file

Hi all, I desperately need a small script which deletes everything in a particular .txt file when "Abs = {" appears till "},", and also when "B-1 = {" appears till "}," I would like all the text in between of those instances to be deleted, however, other text to be unedited (kept as it is).... (12 Replies)
Discussion started by: c_lady
12 Replies

7. Solaris

Is it possible to audit a specific folder or file in Solaris ?

Hi, I wish to audit access to a specific folder or file in Solaris. I have read the man pages for auditd, audit_control , audit_event but don't seem to find any clue. Has anyone tried this before ? Is it feasible ? Any advise is appreciated. Thanks Yik (5 Replies)
Discussion started by: ycheng08
5 Replies

8. Shell Programming and Scripting

How to copy specific files when you don't know the file name?

I hope this isn't as silly as it sounds from the title of the thread. I have software that outputs files where the name starts with a real number followed by underscore as a prefix to an input file name. These will list in the directory with the file with the smallest real number prefix as the... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

9. Shell Programming and Scripting

Execute commands to specific folder from input file

Hi, I have one text file input.txt, which has folders path as follows: /home/user/automate/abc /home/user/automate/abc/xyz /home/user/automate/test /home/user/automate/test2 /home/user/automate/test2/abc/Main In those folders i have .svn folder. 1) First i want to remove .svn like rm... (5 Replies)
Discussion started by: dragon.1431
5 Replies

10. Shell Programming and Scripting

Executing KSH batch file located in specific folder

Ok apologies if this is trivial or doesn't make sense but I am quite new to korn shells; So I have a .ksh batch file located in a folder of my choosing, I want to run this file in a korn shell. The problem though is that I want to get VBA code to do this. I have (VBA) code which opens command... (1 Reply)
Discussion started by: cjsewell
1 Replies
Login or Register to Ask a Question