Print result of mv -n


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Print result of mv -n
# 1  
Old 02-22-2015
Print result of mv -n

I am trying to move files which donot have same filename using

Code:
find /Users/ParijatMac/desktop/unix/new_dir -type f -mmin +"$HRS"  -exec mv -n "{}" /Users/ParijatMac/desktop/unix/old_dir \; -print


but i am getting all filenames including the ones with duplicate names.Please help me to sort this out.
Thanks in advance
# 2  
Old 02-22-2015
Please be more clear about what is happening...

Are source files that have the same name as an existing file in the destination directory disappearing from their source directory?

Are you seeing any output from the mv commands?

What OS and shell are you using? What is the exit code is from mv on your system if the source file name already exists in the destination directory? (If it is exit code 0, the -print primary will print the pathname of the source file even if it is not moved.)
# 3  
Old 02-22-2015
My objective is to move all records from folder 1 to folder 2 which have dissimilar file names. hence i am using
mv -n
Now i want to print these file names which are being moved.I am new to unix and still learning .It would be great if you could guide me
# 4  
Old 02-22-2015
If you would answer the questions I asked in my last post, we might be able to help you. If you choose to ignore my questions, I might be able to come up with a reliable way to do what you want, but there isn't much reason for me to waste time playing guessing games if you refuse to give us answers to the simple questions I asked.

Please help us help you! Answer the questions I asked before:
Quote:
Are source files that have the same name as an existing file in the destination directory disappearing from their source directory?

Are you seeing any output from the mv commands?

What OS and shell are you using?

What is the exit code is from mv on your system if the source file name already exists in the destination directory?
# 5  
Old 02-23-2015
Hi Don,
Sorry for not being clear.
1.No the source file with same name as in destination for are NOT disappearing.The move command is working perfectly fine..
2.The
Code:
mv -n

has no output but is moving the dissimilar files as expected.
3.i am using Unix os bash shell
4.i think what you are asking here is what exits the mv command when it finds a similar file name ,I am using mv -n.

Pardon me if I donot get all your questions as I am new to Unix and new to this forum.

---------- Post updated at 09:35 AM ---------- Previous update was at 09:34 AM ----------

My objective is to print the file names which are being moved
# 6  
Old 02-23-2015
UNIX is not an operating system. UNIX is a brand name for a group of operating systems that meet certain branding requirements. What is the output from the command:
Code:
uname -a

on your system.

You say you want to:
Quote:
move all records from folder 1 to folder 2
where, based on the command you are using, I interpret:
  1. "all records" to be all regular files that have not been modified in a certain number of minutes (where the number of minutes is specified by the expansion of the shell variable named HRS),
  2. "from folder 1" to be the directory named /Users/ParijatMac/desktop/unix/new_dir and every directory under that directory, and
  3. "folder 2" to be the directory named /Users/ParijatMac/desktop/unix/old_dir.
So, do you want to move all regular files, or do you want to move some regular files that have been around for a certain number of minutes, or some regular files that have been around for a certain number of hours? (And why do you use a variable named HRS to specify a number of minutes?)

And, do you want to move those files from a single directory, or do you want to move files from a complete file hierarchy rooted in that directory?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To get or print specific value in result

i am executing below code to achive my result, but for second row the value is not coming it should come URL like other two . url start with http:// and end with .xhtml cat FILE | grep 'Test failed' | awk -F',' '{print $3,$8,$12}' INPUT 1517679173303,84,SKILLED LANGUAGE - ENTER... (11 Replies)
Discussion started by: mirwasim
11 Replies

2. Shell Programming and Scripting

Compare 2 columns from the same file and print a value depending on the result

Hello Unix gurus, I have a file with this format (example values): label1 1 0 label2 1 0 label3 0.4 0.6 label4 0.5 0.5 label5 0.1 0.9 label6 0.9 0.1 in which: column 1 is a row label column 2 and 3 are values I would like to do a simple operation on this table and get the... (8 Replies)
Discussion started by: ksennin
8 Replies

3. Shell Programming and Scripting

Print if found non-desired result

I have a result like this root@server # grep -rl maldet /etc/cron* /etc/cron.d/maldet_daily /etc/cron.d/malcron /etc/cron.d/malcrondaily /etc/cron.d/malcronweekly What I need is, I need an if/else condition such that, if there is any output other than /etc/cron.d/maldet_daily in the... (8 Replies)
Discussion started by: anil510
8 Replies

4. Shell Programming and Scripting

Find a group of result and print last hits

Hi I would like to search some data with awk and then print the last of the hits. Find house and print last value input:red house 4 blue boat 2 green house 6 black car 7 output:6 I now how to search using /house/, print third field print $3, an now I may use some form of $NR to get the... (3 Replies)
Discussion started by: Jotne
3 Replies

5. Shell Programming and Scripting

Use the print result of a script as an argument

Hi all, Say I have a script named script.sh. What it does is to print a line like "abc" #! /usr/bin/ksh print "abc" I would like to pass this value to an external variable, var1="script.sh" However when I echo $var1 I got "script.sh" itself instead of the result? Thanks (3 Replies)
Discussion started by: isaacniu
3 Replies

6. Shell Programming and Scripting

Print the whole line which contains the result of the command cut

Hey everyone I have a file 'agenda' which contains: Object Day Month Year Birthday 09 02 2012 i want to extract from a script the line which contains the day the user typed. for example if he type 09 the line is showed using... (4 Replies)
Discussion started by: Goldstein
4 Replies

7. Shell Programming and Scripting

sort, columns, no result! can I print files of "planes"?

hi, please can I ask you for some help? I have data from 3D situation, x y z value I'd like to use gnuplot to generate maps of the value in the planes z=0 to z=1 for example, my file looks like -0,012 0,0060 0,0 0,13972813076023477 -0,012 0,0064319163 4,2894483E-4 ... (1 Reply)
Discussion started by: kocour
1 Replies

8. Shell Programming and Scripting

Filter the column and print the result based on condition

Hi all This is my output of the some SQL Query TABLESPACE_NAME FILE_NAME TOTALSPACE FREESPACE USEDSPACE Free ------------------------- ------------------------------------------------------- ---------- --------- ---------... (2 Replies)
Discussion started by: jhon
2 Replies

9. Shell Programming and Scripting

print out result from data file

i got a data file which contains all the pid,ppid,user,command,pcpu,start_time,status. I wanted to display out the pcpu which is greater than 0. i uses awk'{if($5 > 0){print}}' filename.txt but is printing out result which not i wanted. Is there any way which i can print out those pcpu which is... (8 Replies)
Discussion started by: thms_sum
8 Replies

10. Shell Programming and Scripting

print a function result in new file

Hi, i have a function which return a variable . serach ( paramatere) when i excute this function i get the result in the shell, i want to print this result in a file by calling just the function. how can i do it.. the code example is like that: search ( ) { .. } the call... (0 Replies)
Discussion started by: kamel.seg
0 Replies
Login or Register to Ask a Question