您使用的是什么操作系统和可执行版本?
你的小脚本:
#!/bin/sh
find . | grep -E ".*\.log$"
或者
#!/bin/bash
find . | grep -E ".*\.log$"
在 Debian Wheezy 上对我来说完美(单反斜杠或双反斜杠)
yba@tavas:~$ bash --version
GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
yba@tavas:~$ grep --version
grep (GNU grep) 2.12
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
你的脚本在什么意义上失败了?
这是示例输出:
yba@tavas:~$ ./st.sh
./Downloads/serial_update_rev11.log
./.virt-manager/virt-manager.log
./Android/adt-bundle-linux/eclipse/configuration/org.eclipse.update/install.log
./Android/workspace/.metadata/.plugins/org.eclipse.cdt.core/.log
./Android/workspace/.metadata/.log
./ti-dvsdk_dm365-evm_4_02_00_06/xdctools_3_16_03_36/eclipse/plugins /org.eclipse.rtsc.xdctools.product_3.16.3.36/META-INF/Make.log
./ti-dvsdk_dm365-evm_4_02_00_06/codecs-dm365_4_02_00_00/packages/ittiam/codecs/g711_dec /hs_err_pid17410.log
./.local/share/gvfs-metadata/root-dfdae0ca.log
./.local/share/gvfs-metadata/label-AR7266WnX\x20V2_1.2-a6becf19.log
./.local/share/gvfs-metadata/home-2def37e1.log
./.local/share/gvfs-metadata/uuid-5c7747c5-81e5-4464-bae0-2c61afc73da4-7a539d2d.log
./.local/share/tracker/tracker-store.log
./.local/share/tracker/tracker-miner-fs.log
./.local/share/tracker/tracker-extract.log
yba@tavas:~$