for loop through files with spaces and some special characters

后端 未结 3 1172
难免孤独
难免孤独 2020-12-22 13:38

I need to run the following command with a for loop

cat Locate\\ Message.eml | ./locatePipe.php

I am trying the following however it seems

相关标签:
3条回答
  • 2020-12-22 14:07

    I accomplished this using the following command

    find -name '*.eml' | while read email; do cat "$email" | ./locatePipe.php; done
    
    0 讨论(0)
  • 2020-12-22 14:15

    If you're using bash 4, just skip using find:

    shopt -s globstar
    for i in **/*.eml; do
        cat "$i"
    done | ./locatePipe.php
    
    0 讨论(0)
  • 2020-12-22 14:16

    Use the -exec option

    find -name '*.eml' -exec cat {} + | ./locatePipe.php
    
    0 讨论(0)
提交回复
热议问题