Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-02-2001, 02:24 PM   #1
Craig Bowes
LQ Newbie
Registered: Apr 2001
Posts: 2

Rep: Reputation: 0

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.
Old 04-02-2001, 04:21 PM   #2
Registered: Mar 2001
Location: Atlanta,GA
Distribution: Red Hat, Mandrake
Posts: 66

Rep: Reputation: 15

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
Old 04-02-2001, 05:27 PM   #3
Craig Bowes
LQ Newbie
Registered: Apr 2001
Posts: 2

Original Poster
Rep: Reputation: 0
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.
Old 10-09-2004, 01:49 PM   #4
LQ Newbie
Registered: Mar 2004
Posts: 1

Rep: Reputation: 0
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cut Command Help!! fooforon Programming 2 02-05-2004 11:09 AM
cut / awk command?? Sammy2ooo Linux - Newbie 1 05-27-2003 06:46 PM
finger - command rob99 Linux - Networking 2 02-02-2003 12:40 PM
finger command shows never logged on...but its not true falconxlc Linux - General 4 12-09-2002 11:26 AM
Easy: Help with Cut command Krash_io Programming 4 07-17-2002 03:29 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:04 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration