I'm trying to write a small script to get me list of files that match certain criteria into a file.
#!/bin/sh
cd /var/www_data/patch/
grep --include=\*.{php,ini,conf,sh} -ril -P "'([\d\w\-\_\.]+)(@domain.com)'" "/var/www_data/something/" 2>&1 > mails
The grep
line works perfectly in command line but if I launch it via script, resulting file will have size of 0 bytes. Any ideas why this is happening?
2>&1 > mails
part, it won't output anything into terminal – Igor Yavych Sep 7 '14 at 12:02{php,ini,conf,sh}
) but your shebang is#!/bin/sh
. Are you sure/bin/sh
is a bash shell on your system - it is often a symlink to a simpler shell such asdash
. – steeldriver Sep 7 '14 at 13:22