Moving latest files from one directory to another
Solution 1
Your issue is due to the fact that you've taken control of the formatting of the output generated by find
, splitting on newlines now, \n
. In order to get xargs
to process your output when using -0
the output needs to be separated by null characters, \0
. Here's an easy way to fix it though:
$ find . -type f -printf "%C@ %p\n" | sort | tail -n 2 | \
cut -d " " -f 2- | tr '\n' '\0' | xargs -0 mv -t /app/path1/path2/path3
The introduction of the `tr '\n' '\0' command converts the new lines back to nulls.
Solution 2
Either avoid -0 option with xargs, or use -print0. A snippet from the man page for xargs
In these situations it is better to use the -0 option, which prevents such problems. When using this option you will need to ensure that the program which produces the input for xargs also uses a null character as a separator. If that program is GNU find for example, the -print0 option does this for you.
Related videos on Youtube
JohnRoach
Updated on September 18, 2022Comments
-
JohnRoach over 1 year
I have come across an interesting problem. I first created a model. And syncdb'ed it. Later on I changed the model by adding one models.DateField() and a models.DateTime(). Than I re syncdb'ed it... However the when I checked the database the rows were not added. Is this normal behaviour or did I do something wrong? Later on I deleted all tables and syncdb'ed and got all rows with no problems.
-
Raunak Agarwal over 11 yearsDjango syncdb would only help you to get the initial schema design. It can not make the alteration provided later on. Try using Django South to do this for you
-
-
slm almost 10 years@user67186 - great. Please mark this as accepted so other's know your issues been resolved.