Monday 15 April 2013

bash - Use tr to remove line breaks in multiple files? -



bash - Use tr to remove line breaks in multiple files? -

i have set of several hundred .txt files analyzing (ngram analysis using nsp), , need remove line breaks each file. can 1 @ time using tr:

$ tr -d "\n\r" < input1.txt > output1.txt

how can entire directory of files @ once?

this add together -out before .txt. haven't specified filenames like, other .txt, don't have input files named foo-out.txt, etc.

for f in *.txt tr -d "\n\r" < $f > $(basename $f .txt)-out.txt done

bash for-loop newline tr file-manipulation

No comments:

Post a Comment