The UNIX and Linux Forums  


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
Script required to get a required info from file. Pls. help me. ntgobinath Shell Programming and Scripting 2 05-31-2008 09:34 AM
Help required on awk meetavin Shell Programming and Scripting 3 04-18-2008 10:47 AM
SSL help required binums HP-UX 0 05-04-2006 03:03 AM
Help required on DBX Sumanth SUN Solaris 1 07-29-2004 10:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-27-2006
Amardeep Amardeep is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 22
help required with cut -d

i have a file in which data is like this

12 34 56 78
78 56 34 12

now i want to cut 2nd last column....

if 2nd column from start is to be cut then i can write

cut -d" " -f2 filename

what to do if 2nd column from end is to be cut !

any help

thanks
Sidhu
  #2 (permalink)  
Old 11-27-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Do you have to use cut? awk will work very well here.

Code:
echo "12 34 56 78
78 56 34 12" | awk '{print $(NF-1)}'

  #3 (permalink)  
Old 11-27-2006
Amardeep Amardeep is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 22
with cut

is there any way we can do it with cut ?

also with awk if i need to read from file then how m going to do it...couldnt get a clue...actually touching linux after long time
  #4 (permalink)  
Old 11-27-2006
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
try this


Code:
cat file_name | awk '{print $(NF-1)}'

  #5 (permalink)  
Old 11-27-2006
Amardeep Amardeep is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 22
thanks !

thanks
it is perfect !
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 09:00 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