The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Retrieve 5th Field to Last Field !! jobbyjoseph UNIX for Dummies Questions & Answers 3 05-16-2007 03:20 AM
Moving Part of a field to another field using AWK rjsha1 Shell Programming and Scripting 5 08-04-2006 05:39 AM
add increment field when first field changes azekry Shell Programming and Scripting 2 11-14-2005 04:21 PM
TTL field??? solvman UNIX for Advanced & Expert Users 11 10-12-2001 12:54 AM
awk sub-field? kristy UNIX for Dummies Questions & Answers 2 10-05-2001 04:07 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-08-2003
435 Gavea 435 Gavea is offline
Registered User
  
 

Join Date: Oct 2003
Location: Brazil
Posts: 42
Cut the last field

Hello guys.

Is there any way I can cut the last field using "cut" ???


(without putting it into a while...)

Thanks.
435 Gavea.
  #2 (permalink)  
Old 12-08-2003
Optimus_P Optimus_P is offline Forum Advisor  
flim flam flamma jamma
  
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
your question is kinda vague.

what are you trying to do that you want to avoid a while loop?
  #3 (permalink)  
Old 12-08-2003
linuxpenguin's Avatar
linuxpenguin linuxpenguin is offline Forum Advisor  
Registered User
  
 

Join Date: May 2002
Location: India
Posts: 295
not sure how you would use the cut
but you can try this
awk '{print $NF}'

instead of cut

so if you have

line="hhh kkk lll iii ddd kkke"
then
echo $line|awk '{print $NF}'

will give you kkke

give a sample input and output, so that we can help you understand even better
  #4 (permalink)  
Old 12-08-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
You didn't like the answer you got last time?
  #5 (permalink)  
Old 12-08-2003
435 Gavea 435 Gavea is offline
Registered User
  
 

Join Date: Oct 2003
Location: Brazil
Posts: 42
Does the awk solution works with different delimiters ?

I was talking about something like this:

abcd/efgh/ijklm/nopq

And I'd like to "cut" only the nopq
  #6 (permalink)  
Old 12-08-2003
linuxpenguin's Avatar
linuxpenguin linuxpenguin is offline Forum Advisor  
Registered User
  
 

Join Date: May 2002
Location: India
Posts: 295
you can specify the delimiter using the -F option

awk -F/ '{.....

try to use the man pages in case you need any information of a unix command

awk by itself is a very powerful tool. Even if your purpose is served at present I would recommend you to go through the man page of the awk filter

Besides if you search the forum for awk, you will get lotsa information

happy awking
  #7 (permalink)  
Old 12-09-2003
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
I can also recommend the manual pages for the dirname and basename commands.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0