我怎样才能让xargs处理包含空格的文件名? [英] How can I make xargs handle filenames that contain spaces?

查看:149
本文介绍了我怎样才能让xargs处理包含空格的文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ ls *mp3 | xargs mplayer  

Playing Lemon.  
File not found: 'Lemon'  
Playing Tree.mp3.  
File not found: 'Tree.mp3'  

Exiting... (End of file)  

我的命令失败,因为文件Lemon Tree.mp3包含空格,所以xargs认为它是两个文件。我可以使find + xargs像这样的文件名工作吗?

My command fails because the file "Lemon Tree.mp3" contains spaces and so xargs thinks it's two files. Can I make find + xargs work with filenames like this?

推荐答案

您可以将分隔符更改为新行('\ n')为xargs与-d选项是这样的:

You can change the delimiter character to new line ('\n') for xargs with -d option like this:

ls *mp3 | xargs -d '\n' mplayer

这篇关于我怎样才能让xargs处理包含空格的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆