문제

so far I have gotten this far:

prompt$ find path/to/project -type f | grep -v '*.ori|*.pte|*.uh|*.mna' | xargs dos2unix 2> log.txt

However, the files with extensions .ori, .pte, .uh and .mna still show up.

도움이 되었습니까?

해결책

It is better to leave the excluding to find, see Birei's answer.

The problem with your grep pattern is that you have specified it as a shell glob. By default grep expects basic regular expressions (BRE) as its first argument. So if you replace your grep pattern with: .*\.\(ori\|pte\|uh\|mna\)$ it should work. Or if you would rather use extended regular expressions (ERE), you can enable them with -E. Then you can express the same exclusion like this: .*\.(ori|pte|uh|mna)$.

Full command-line:

find . -type f | grep -vE '.*\.(ori|pte|uh|mna)$'

다른 팁

One way:

find path/to/project *.* -type f ! \( -name '*.ori' -o -name '*.pte' -o -name '*.uh' -o -name '*.mna' \) 
  | xargs dos2unix 2> log.txt
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top