用于命名设备上视频的 Shell 脚本
我有一个 .sh 脚本,可以自动挂载插入的任何 USB 设备。我还需要它来查找插入的设备上的某个位置是否有视频,然后将它们写入 videos.txt 文件。这是我所拥有的,但它不起作用。我还需要它将挂载点放入videos.txt 文件中。 ${MOUNTPOINT}$count 是已安装设备的路径。
VIDEOS=ls ${MOUNTPOINT}$count/dcim/100Video | grep mp4
if [ "$VIDEOS" -ne "" ] ; then
"${MOUNTPOINT}$count" > ${MOUNTPOINT}$count/videos.txt;
"$VIDEOS" >> ${MOUNTPOINT}$count/videos.txt;
fi
我做错了什么?
I have a .sh script that automounts any usb device that is plugged in. I need it to also find if there are videos in a certain location on the device that is plugged in then write them to a videos.txt file. Here's what I have and its not working. Also I need it to put the mountpoint in the videos.txt file. ${MOUNTPOINT}$count is the path to the mounted device.
VIDEOS=ls ${MOUNTPOINT}$count/dcim/100Video | grep mp4
if [ "$VIDEOS" -ne "" ] ; then
"${MOUNTPOINT}$count" > ${MOUNTPOINT}$count/videos.txt;
"$VIDEOS" >> ${MOUNTPOINT}$count/videos.txt;
fi
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
$()
执行过程并返回一个值。使用-n
测试来检查非零字符串。-ne
用于检查数字。$VIDEOS
本身是一个字符串,而不是命令。为了将值放入文件中,您应该echo
它。use
$()
to execute process and return a value. use-n
test to check for non-zero strings.-ne
is used to check for numbers.$VIDEOS
by itself is a string, not a command. in order to put a value into a file, you shouldecho
it.