Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # 23. b)
- # Write a shell script that for each file from the command line will output the
- # number of words that are longer than the number k read from keyboard.
- # The output must be ordered by the number of words.
- echo Enter the number
- read k
- for file in $* # this iterates through all the files given in the comm line
- do
- # now it will compare the size of each word from the files given and save
- # the ones longer than the nr
- # wc -l will give the number of those words, and the final output will show
- # the number for each file along with the file name, ordered
- echo "$(awk -v nr=$k '{ for (i=1; i<=NF; i++)
- if (length($i) > nr) print $i
- }' "$file" |
- wc -l) $file" | sort -n
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement