-1

Possible Duplicate:
How do I apply a shell command to many files in nested (and poorly escaped) subdirectories?

I am using this loop to remove empty lines in all files under given directories and sub directories. But it is not working

for file in /home/zubinan/public_html/src/Acme/*/*.php
do
sed '/^$/d' $file > tt
mv tt $file
done

It says Demo is a directory

Community
  • 1
  • 1
Mirage
  • 30,868
  • 62
  • 166
  • 261

4 Answers4

1

Try this;

for fname in `find /home/zubinan/public_html/src/Acme/ -type f`
do
    sed '/^$/d' $fname > tt
    mv tt $fname
done
Rohan
  • 52,392
  • 12
  • 90
  • 87
0

If you want process all specified files in some directory, you can use this oneliner:

sed -i '/^$/d' `find /home/zubinan/public_html/src/Acme -name "*.php"`
Cyprian
  • 11,174
  • 1
  • 48
  • 45
0
for f in $(find /home/zubinan/public_html/src/Acme -type f \( -iname *.php \)); 
    do 
        relfilePath=${f:${#currentpath}:${#f}};
        // use  relfilePath here

    done
Nirmal- thInk beYond
  • 11,847
  • 8
  • 35
  • 46
0

or try this:

 find /home/zubinan/public_html/src/Acme/ -type f -name "*.php" -exec sed -e '/^$/d' -i \{\} \;
umläute
  • 28,885
  • 9
  • 68
  • 122