LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-19-2005, 03:48 PM   #1
krock923
Member
 
Registered: Jul 2004
Posts: 171

Rep: Reputation: 30
cut question


is it possible instead of setting -f 2 or -f 3 to set the field to be whatever the last instance of the delimiter is?
 
Old 10-19-2005, 04:03 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Hmmm... I don't know if it's just me, but that question doesn't make much sense: "whatever the last instance of the delimiter is"

The delimiter is going to be the same throughout the expression. As far as I know, cut only supports one delimiter character. So the last delimited will always be the same as the first...

However, what I think you're asking is how to display the last field regardless of how many delimiters are present. I don't think cut can do that for you, but you can do it rather simply with awk:
Code:
echo "1.2.3.4.5.six" | awk -F '.' '{print $NF}'

Last edited by Dark_Helmet; 10-19-2005 at 04:04 PM.
 
  


Reply



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
Shell scripting question about cut JimBass Linux - Newbie 8 10-20-2005 11:24 PM
Ls and cut problem Phiebie Debian 2 07-14-2005 07:10 AM
simple bash question about cut perfect_circle Programming 2 05-17-2005 11:25 AM
Ok, maybe I'm not cut out for linux... goosegg Linux - Newbie 5 09-01-2003 03:43 PM
cut and paste c0c0deuz Linux - Newbie 6 11-01-2001 12:38 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration