User:Apandith

1. Search Pattern - awk '/foo/ { print $0 }' BBS-list

2. Print the length of the longest input line: - awk '{ if (length($0) > max) max = length($0) } END { print max }' BBS-list

3. Print every line that is longer than 80 characters: - awk 'length($0) > 80' BBS-list

4. Print the length of the longest line in data: - expand BBS-list | awk '{ if (x < length) x = length } END { print "maximum line length is " x }'

5. Print every line that has at least one field: - awk 'NF > 0' data

6. Print seven random numbers from 0 to 100, inclusive: - awk 'BEGIN { for (i = 1; i <= 7; i++) print int(101 * rand) }'

7 Print the total number of bytes used by files: - ls -l files | awk '{ x += $5 } END { print "total bytes: " x }'

8. Print the total number of kilobytes used by files: - ls -l files | awk '{ x += $5 } END { print "total K-bytes: " (x + 1023)/1024 }'

9. Print a sorted list of the login names of all users: - awk -F: '{ print $1 }' /etc/passwd | sort

10. Count the lines in a file: - awk 'END { print NR }' data

11. Print the even-numbered lines in the data file: - awk 'NR % 2 == 0' data