0

Assuming I have a file called "students" containing this:

NEWTON Isaac MAXWELL James EDISON Thomas TESLA Nikola 

how I am supposed to sort these names with a bash script in shell ? Do I need to use a delimiter with carriage return ? Will this support accentuated characters ?

Thanks for your time.

3
  • On SO we do encourage people to add their efforts in their post, kindly do so and let us know then. Commented Sep 23, 2019 at 13:25
  • sort based on first name or last name ? Please give details of the expected output Commented Sep 23, 2019 at 13:26
  • Unclear what your problem is. The sort command with no options should do exactly what you are asking. Commented Sep 23, 2019 at 13:27

1 Answer 1

0

You can make use of the sort function.

$ cat stud.txt NEWTON Isaac MAXWELL James EDISON Thomas TESLA Nikola $ sort stud.txt EDISON Thomas MAXWELL James NEWTON Isaac TESLA Nikola 

To sort on last name, use the -k option.

$ sort -k 2 stud.txt NEWTON Isaac MAXWELL James TESLA Nikola EDISON Thomas 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.