I am taking a linux class in school and am having trouble with the cut command. I have to use finger then pipe it to cut and cut out the first and last name only.
The cut commands that I know are -c and -f but I do not know how to cut the first and last name and leave the middle initial. Help is greatly appreciated. |
finger <username> | cut -c25-33,35-40 >> <filename>
the -c is character spaces(then you put the numbers of the spaces you want to cut) the -f is fields the -d is delimiter of the field ( :/' ', etc...) play with it to get what works best for you. Also, try 'man cut' for more info |
finger and cut
I understand the -c1-10,15-30 cuts the characters, the problem is that the names are different lenghts. I tried cutting fields 3-5 and I did cut out the first name middle initial and last name, so i tried cuting fields 3 and 5 which worked fine for the first name then it when hay wire after that giving me only first names or just last names or first names with middle initials. The instructor put a name at the beginning to through off cutting the fields out and I am at a loss as how to get around it.
|
double pipe
A fairly easy way to do this is to double-pipe your command.
something like: finger abrown | cut -d: -f3 | cut -d\ -f2,4 |
All times are GMT -5. The time now is 12:33 AM. |