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
c program to extract text between two delimiters from some text file kukretiabhi13 High Level Programming 7 12-03-2008 06:29 PM
Extract text in 2 columns of output file. Danish Shakil Shell Programming and Scripting 2 10-19-2007 10:03 AM
How to extract text from xml file chrisf Shell Programming and Scripting 3 09-01-2007 02:25 PM
merging few columns of two text files to a new file kolvi Shell Programming and Scripting 4 09-15-2005 04:34 AM
How to extract data from a text file negixx Shell Programming and Scripting 1 07-19-2005 09:30 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 05-04-2008
ihot ihot is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 19
how to extract columns from a text file

Hi,
In ksh, I have a file with similar rows as follows:
Department = 1234 G/L Asset Acct No = 12.0000. 2/29/2008
Department = 1234 G/L Asset Acct No = 13.0000. 3/29/2008.

I want to create a new text file that contains only the numbers and date:
1234 12.0000. 2/29/2008
1234 13.0000. 3/29/2008

Should I use "cut" to cut out what I need?
Also, how do I make sure blank lines in original file do not get copied over to the new file?
Thanks in advance.
  #2 (permalink)  
Old 05-04-2008
swamymns swamymns is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 25
hi,
try this,

awk '{print $9$10}' test > new_file

where the content of test is ,
Department = 1234 G/L Asset Acct No = 12.0000. 2/29/2008
Department = 1234 G/L Asset Acct No = 13.0000. 3/29/2008
  #3 (permalink)  
Old 05-04-2008
tjmannonline tjmannonline is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 91
you forget $3
  #4 (permalink)  
Old 05-04-2008
learnbash learnbash is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 96
Wink

with spaces we can use actual like that.

awk '{print $3 " " $9 " " $10}' afile

1234 12.0000. 2/29/2008
1234 13.0000. 3/29/2008

Regards,
Bash
  #5 (permalink)  
Old 05-04-2008
learnbash learnbash is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 96
Wink

This can also help.

cut -f 3,9,10 -d ' ' afile

1234 12.0000. 2/29/2008
1234 13.0000. 3/29/2008

Regards,
Bash
  #6 (permalink)  
Old 05-04-2008
ihot ihot is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 19
you guys are the greatest.

Thanks a million gentlement...You guys are the greatest. You just helped out a deptartment in high tech company in Silicon Valley.
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 11:06 PM.


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