LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 04-02-2001, 01: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, 03:21 PM   #2
killjoy
Member
 
Registered: Mar 2001
Location: Atlanta,GA
Distribution: Red Hat, Mandrake
Posts: 66

Rep: Reputation: 15
Smile

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, 04: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, 12:49 PM   #4
evilninja
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
 
  


Reply


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 10:09 AM
cut / awk command?? Sammy2ooo Linux - Newbie 1 05-27-2003 05:46 PM
finger - command rob99 Linux - Networking 2 02-02-2003 11:40 AM
finger command shows never logged on...but its not true falconxlc Linux - General 4 12-09-2002 10:26 AM
Easy: Help with Cut command Krash_io Programming 4 07-17-2002 02:29 AM


All times are GMT -5. The time now is 11:06 AM.

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