Hi!
I've run into a problem where my variables are displayed in the wrong order. Basically I'm supposed to use a file that has information like this username:firstname:lastname:etc:etc.
What I'm interested in doing is reformating it into a something more like this: username lastname, firstname.
This is the code I have so far:
#!/bin/sh
#This script will read a file and then display the important #details: username and full name.
#The list will be sorted by last name.
for i in 29
do
USER_ID=$(sort -t: -k3 studenter.txt | head -$i | cut -c1-8)
FIRST_NAME=$(sort -t: -k3 studenter.txt | head -$i | cut -f2 -d:)
LAST_NAME=$(sort -t: -k3 studenter.txt | head -$i | cut -f3 -d:)
echo "$USER_ID $LAST_NAME, $FIRST_NAME"
done
When I run it in terminal it just displays all the usernames and then lastnames and then firstnames.
Thank you in advance!