LinuxQuestions.org
Review your favorite Linux distribution.
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, 04: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, 05:03 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
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 05:04 PM.
 
  


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


All times are GMT -5. The time now is 02:24 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration