I'm c开发者_开发百科urrently using the following to split a file into words - Is there some quicker way?
while read -r line
do
for word in $line
do
words="${words}\n${word}"
done
done
What about using tr?
tr -s '[:space:]' '\n' < myfile.txt
The -s
squeezes multiple whitespace characters into one.
xargs -n 1 echo <myfile.txt
sed 's/[[:space:]]/\n/g' file.txt
精彩评论