Question

If you have a file named phone-numbers.txt that looks like this: 207-568-6723 617-277-2343 207-822-9645 603-314-5892 800-233-3413...

If you have a file named phone-numbers.txt that looks like this:

207-568-6723
617-277-2343
207-822-9645
603-314-5892
800-233-3413

Doing "sort phone-numbers.txt" will end up sorting by area code.

What if you want to sort by the last 4 numbers?

sort -n phone-numbers.txt

sort -t\- -k3 phone-numbers.txt

sort [[:allnum:]]$ phone-numbers.txt

cat -r phone-numbers.txt | sort -rn

0 0
Add a comment Improve this question Transcribed image text
Answer #1

sort -t\- -k3 phone-numbers.txt

Add a comment
Know the answer?
Add Answer to:
If you have a file named phone-numbers.txt that looks like this: 207-568-6723 617-277-2343 207-822-9645 603-314-5892 800-233-3413...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a program that will use the attached input file and perform the following operations. Read...

    Create a program that will use the attached input file and perform the following operations. Read the file into an appropriate JCF data structure. Look up a (list of) names and numbers matching a last name or the first letters of a last name, ignoring case. Look up a (list of) names and numbers matching a number or the first digits of a number. Add a name and number to the list. Sort the list by first name, last name...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT