I hope somebody could help me with a couple of things...
First, I would like to search the /etc/passwd file for the full name of a user given his/her username. i've tried the following command:
cat etc/passwd | grep -w '`whoami`' | cut -f 5 -d ':'
of course that didn't work as grep interprets whoami as a string, not as a command becuase of the ' '.
So does anyone know how i can get over this problem?
Second, i have a text file that contains a names of items, the price, and the date it was purchased. The content looks something like this:
t-shirt|20|-
socks|10|2004-12-10
shoes|40|2004-12-10
the item name, price and date are separated by '|' and the '-' denotes that the item wasnt purchased yet
So what i need to do here is to echo the unpurchased items and then the purchased items, i used grep to do this and it worked.
But to add, what i needed was to add a number before each item as it is displayed on the screen, something like this:
UNpurchased items:
1. tshirt 20
purchased items:
1. socks 10
2. shoes 40
they also need to be aligned as shown, can anyone show me how to do this? Help would be very mush appreciated.
Sincerely,
marco83