Working with grep-output

view story

http://www.unix.com – Hi, 1st post Sorry for borrowing the thread. Hopefully this is doable. I need to write a script where I need to pick information from my grep-results. Code: grep -n "s_" file | head -n 1 Output is like this: Code: 6:s_9: 11-664 Fam_g442_99 So this gives me the first line of the file which includes "s_" . I need to pick those s_9, 11-664 and Fam_c606_1 separately that the script can rename the txt-file's subfolders with this information. After this is done, my script will do the grep with | head -n 2 and repeat the sequence. Many thanks in advance (HowTos)