I'm new to linux and i decided to learn shell scripting. I have created a file data.txt that contains the following text:
12345 Nick Abrams A 10900
67890 George Kennedy I 20000
(text goes on...)
The first field is a card's pin number, the second is the name of the client, third is surname, fourth indicates whether a card is active (or inactive) and the last field is the client's balance. I need to write a script that receives the client's pin from keyboard and if that pin is written in the text file then the script should print the client's name and surname on the screen. I have used grep like this
grep "^$pin" data.txt
But it returns all the details of a client. I only need to print the second and third field and ignore everything else. Is there any parameter to isolate the words i need?