Copy Files then with option of remove


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy Files then with option of remove
# 1  
Old 08-05-2005
Copy Files then with option of remove

hi,

i encounter a quite a new things for me.

lets sat my test.txt modified date is 6th of July 2005.

then i execute the following command:

"cp test.txt testfolder/test.txt"

when i go to execute "ls -l" command...
the test.txt modified date become today date!

but if i execute:

"cp test.txt testfolder/test.txt"
"rm test.txt"

the modified date i get it 6th of July 2005.

Can anyone enlighten me with these?
Thanks!
# 2  
Old 08-05-2005
Computer U Lost In Thoughts?????

Hey wat ever u said is not at all true....
I think u r running the 'ls -l' in the testdir which correctly shows u the current timestamp while after removing the file in testdir u r running the ls in the original dir which will always be showing the 6th july date( if it is not touched after tat)...it seems u were lost in the thoughts of some.....
# 3  
Old 08-05-2005
btw... i forgot to say is that i put that in a script...

example:
Quote:
find $OUTQUEUE -name \*.*.* -newer $from_file ! -newer $to_file| while read LST_FILES;
do
cp $LST_FILES $FINAL_DIR
rm $LST_FILES
done
# 4  
Old 08-05-2005
Try cp -p to preserve timestamps.
# 5  
Old 08-05-2005
Quote:
Originally Posted by Ygor
Try cp -p to preserve timestamps.
ya... i use -p and it works...
but i just puzzle with what happened cos i discover that issue accidentally because i forgot to put -p in my script Smilie
# 6  
Old 08-16-2005
anyone know why?
i am using AIX machine.
thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. OS X (Apple)

Copy files between partitions with "without auto-mount" option enabled - possible?

Hello, fellow Unixers and Macers, I'll run several OS X versions each on its own dedicated partition. Partitions won't be seeing each other (by editing fstab). Question: will I be able to copy files between those partitions? Partition #1: Mavericks. Partition #2: HighSierra (2 Replies)
Discussion started by: scrutinizerix
2 Replies

2. Shell Programming and Scripting

Alternate to copy + remove

is there any single command for cat file1 > file2 cp /dev/null file1 The original file must retain intact but it should get empty. Actually, the contents needs to be processed by another process and for new entries, the file must remain there with zero records. (4 Replies)
Discussion started by: busyboy
4 Replies

3. Shell Programming and Scripting

List only hidden files, not use . option

Hi I have a prompt like this: PS1='\\u@\h \\w $(es=$?; ] && echo "\" || echo "\")\$\' It works like it should, but have a bug. Problem is the counting of hidden files $(($(ls -ad .* | wc -l)-2)) echo $(($(ls -ad .* | wc -l)-2)) The . seems to create the problem when I cut and past to... (3 Replies)
Discussion started by: Jotne
3 Replies

4. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

5. Shell Programming and Scripting

Remove Command-Line Option from String

I want to add a "-r <remote_host>" option to my ksh script, causing the script to run a script of the same name on the specified remote host. The remote invocation should itself include all the command-line options of the original invocation, less the -r option. For example, this invocation: ... (7 Replies)
Discussion started by: mattmiller
7 Replies

6. Shell Programming and Scripting

Copy Option

I need to be able to choose an option in order to copy a file. So far, I have this: echo "Please input file name after option and use -c to copy, -r replace, or -x to delete" if then echo "You must provide a filename!" exit 1 fi if then cp -- "$@" echo... (5 Replies)
Discussion started by: squardius
5 Replies

7. UNIX for Advanced & Expert Users

Problem with Carbon copy (CC) option in mailx command

Hi, I have problems with the cc option in mailx command. Just went through some of the similar threads but none provides a satisfactory explanation. I have a script using the mailx command in the following way: (echo `cat mailsub.txt` ; uuencode attachment.csv attachment.csv) | mailx -s... (2 Replies)
Discussion started by: SmithaN
2 Replies

8. UNIX for Dummies Questions & Answers

copy all files and folders and cjange or remove ownership

So tried: cp -r -p test1/ user@machine:///srv/www/vhosts/domain.co.uk/httpdocs/backup/ but this didn't work either :( Anyone able to help with this? Many thanks Mr M (3 Replies)
Discussion started by: misterm
3 Replies

9. UNIX for Dummies Questions & Answers

Copy all the files with time stamp and remove header,trailer from file

All, I am new to unix and i have the following requirement. I have file(s) landing into input directory with timestamp, first i want to copy all these files into seperate directory then i want to rename these files without timestamp and also remove header,trailer from that file.. Could... (35 Replies)
Discussion started by: ksrams
35 Replies

10. Shell Programming and Scripting

finding files using prune option

Hi All, I am trying to find files in a directory and don't want to search in the sub directories and using the command find . \( ! -name . -prune \) -mtime +1 -name '*.log' and is working fine. But when I am trying with absolute path then is not working like find /home/subodh \( ! -name... (1 Reply)
Discussion started by: subodh.sharma
1 Replies
Login or Register to Ask a Question