我想使用Git Bash将我最近下载的3个文件复制到另一个目录。我可以用Git Bash Windows:管道输出ls -t | head -n 3到cp
ls -t ~/Downloads|head -n 3
一一列举了,但我怎么将它们作为输入到CP的功能,这样我可以 将它们拷贝到其他目录?
我很新的编程和Bash,所以我很抱歉,如果这是显而易见的。
我想使用Git Bash将我最近下载的3个文件复制到另一个目录。我可以用Git Bash Windows:管道输出ls -t | head -n 3到cp
ls -t ~/Downloads|head -n 3
一一列举了,但我怎么将它们作为输入到CP的功能,这样我可以 将它们拷贝到其他目录?
我很新的编程和Bash,所以我很抱歉,如果这是显而易见的。
注意:你不需要的Git的bash复制这些文件:如果你已经添加<git>/usr/bin
您%PATH%
(如I do here, with this simplified PATH
),你可以在任何常规CMD
会议Linux命令序列:
[email protected] D:\git\git
> where xargs
D:\prgs\git\latest\usr\bin\xargs.exe
[email protected] D:\git\git
> ls -t|head -3|xargs | xargs -I\{\} echo "{}" a
wt-status.h wt-status.c worktree.h a
另请参阅“pass output as an argument for cp
in bash”,其中提到了xargs。
其他选项(cp $(ls -t | head -3) Directory
)必须只在bash中。
谢谢你的回复! –
@RawNoob当然。不要忘记阅读https://stackoverflow.com/help/someone-answers – VonC
这与git无关,实际上只是一个bash问题。你在找什么是xargs。 –