Tag Info

New answers tagged

0

If you don't need the new files to be contiguous chunks of the original file, you can do this entirely with sed in the following way: sed -n -e '1~16,+3w1.txt' -e '5~16,+3w2.txt' -e '9~16,+3w3.txt' -e '13~16,+3w4.txt' The -n stops it from printing each line, and each of the -e scripts is essentially doing the same thing. 1~16 matches the first line, and ...


2

Since you tagged your question with wc, here's a solution (albeit non-optimal) that uses it: while read -r line; do echo $line | wc -w; done < filename.txt


3

You can do it with: awk '{print NF}' filename


1

find . -name \[123]_file.txt -exec cat {} + | tr -sc \> \\n | wc -l ...will work for sequences of your single character example. But if the string is more complex, then is probably a good idea to go with the -only GNU switch to grep. Like: find . -name \[123]_file.txt -exec grep -o \> {} + | wc -l



Top 50 recent answers are included