MacOS terminal cp does not do anything and shows usage instruction - operating-system

I am running this from my terminal:
cp build/*.js /Users/amin/servers/tomcat/work/static/vaadin/
But the command just shows me usage instructions, and does not copy the files:
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory
Does anyone know what I did wrong?

This happened to me once, and my problem was that the directory I was copying to, didn't exist. Does yours?

Related

find with xargs runs successfully but no changes to file

I run a command to batch process image files using resmushit:
find /home/user/image/data -type f -print0 | xargs -n 1 -P 10 -0 resmushit -q 85 --preserve-filename
The command runs successfully and tells me the files were optimized and saved however when I check the files in the folder there is no change.
edit: it looks like the problem might be with resmushit. When I run it on pictures within my working directory it works. i.e
resmushit -q 85 --preserve-filename test.jpg
Is there a way to make xargs or a different command to run the command within each folder recursively?
I ended finding for directories and using a bash file so:
find /home/user/image/data -type d -print0 | xargs -n 1 -P 10 -0 bashscript
and the script is:
#!/bin/sh
cd "$*"
resmushit -q 85 --preserve-filename *

UNIX: How to move a last created file to a certain directory through terminal

I am able to get the file name of a last created/modified file in a current directory with this command:
ls -t | head -n1
then the obtained file name I use it with mv command to move it to a directory.
and I'm trying to do it like this:
mv $(ls -t | head -n1) directory/
But it doesn't move the file.
What am I doing wrong?
Maybe like this:
mv "$(ls -t | head -n1)" directory/

find dir xargs rm output to a file.log

I have a bash script, in the end will find folders with modified timestamps greater than 5 days then pipe it to xargs to rm. This is working fine and to print the command I am using -t option for the xargs as well. But I need this output written to a log file.
so my command line is as follows :
find /tmp/test -type d -mtime +5 -print0 | xargs -t -0 -I {} /bin/rm -rf '{}'
I would like to get the output to know which all folders are deleted to a file named rmdirs.log
I tried redirecting it to a file but like below and it wont work;
find /tmp/test -type d -mtime +5 -print0 | xargs -t -0 -I {} /bin/rm -rf '{}' >> rmdirs.log
Any help would be much appreciated.
I created a test environment with touch. This properly deletes the directory and logs the ones deleted to rmdirs.log file.
touch -t 202201010000 tmp/test/old
touch tmp/test/new
find tmp/test -type d -mtime +5 -print | \
tee -a rmdirs.log | \
tr '\12' '\0' | \
xargs -0 -I {} /bin/rm -rf {}
Use teeto append (-a) to the rmdirs.log file.
Use tr to convert the newlines (\12) to null (\0) for safety.
Finally run xargs to remove the files.

how to create folder recursively

there are two file path .
now i am in eee folder
/Volumes/aaa/bbb/ccc/ddd/eee/text.txt
1) i am going to mv text.txt file to below path
/Volumes/aaa/bbb/ccc/ddd_1/eee/text.txt
or just create folder structure only
/Volumes/aaa/bbb/ccc/ddd_1/eee/
with below command with recursively , but not works all
there are some solution related with this .
but not works .
mkdir -p $(`pwd | sed 's/ddd/ddd_l/'`)
or
rsync -av -f"+ */" -f"- *" "$pwd" "$(`pwd | sed 's/ddd/ddd_l/'`)"
or
mv test.MTS `pwd | sed 's/ddd/ddd_l/'`
or
cp -R test.MTS `pwd | sed 's/ddd/ddd_l/'`
who can do this ?
Try this:
new_file="/Volumes/aaa/bbb/ccc/ddd/eee/text.txt"
mkdir -p "$(dirname "$new_file")"
touch "$new_file"

How to determine date/time when a file was first added to CVS repository

Is there any simple cvs command through which I can get date/time when a file was first added to the module in CVS repository.
I actually want a one line output that can be consumed by my some script.
This is not directly possible in CVS. One can get activity logs for a file and then identify the date from them. Following is the single line command that works like a charm and gives the date when the file was first added in the repository.
cvs -Q -d :pserver:*User*:*Pass*#*HostName*:/cvsroot rlog -N *FilePath* | grep ^date: | sort | head -n 1 | cut -d\; -f1 | sed -e 's/date: //'
Above command looks through the entire repository and gives the date. If one is looking for first activity on that file on a branch use following commands.
For Branch:
cvs -Q -d :pserver:*User*:*Pass*#*HostName*:/cvsroot rlog -N -r*BranchName* *FilePath* | grep ^date: | sort | head -n 1 | cut -d\; -f1 | sed -e 's/date: //'
For Trunk:
cvs -Q -d :pserver:*User*:*Pass*#*HostName*:/cvsroot rlog -N -r::HEAD *FilePath* | grep ^date: | sort | head -n 1 | cut -d\; -f1 | sed -e 's/date: //'