Step 1: read the file
Step 2. Replace the spaces with a new line and save the result in a temporary file
Step 3: Get only lines containing '_' from the temporary file and save it in multiwords.txt
Step 4. Exclude lines containing "-" from the temporary file, then save the result in singlewords.txt
Step 5. Delete the temporary file
cat file | tr ' ' '\n' > tmp.txt | grep '_' tmp.txt > multiwords.txt | grep -v '_' tmp.txt > singlewords.txt | find . -type f -name 'tmp.txt' -delete
source share