I have a file /tmp/a.txt
with following content:
1
2
3
4
5
Using AWK
, I want to prompt user to specify a range in any of the following formats and print the matching lines.
comma separated
1,2,3
space separated
1 2 3
and in range using -
1-3
Expected Output:
1
2
3
Below is the sample awk command to capture input from user, what should I put here to get the required output.
awk 'BEGIN { printf "Enter the range: " ; getline name < "-" }{?}' /tmp/a.txt