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
Script to open program and send/execute command in program tuathan UNIX for Dummies Questions & Answers 1 11-19-2008 09:59 PM
A program to trace execution of another program jiten_hegde High Level Programming 3 08-19-2008 05:26 AM
How to write to stdin of another program (program A -> [stdin]program B) vvaidyan UNIX for Dummies Questions & Answers 3 08-02-2008 05:21 PM
How to write to stdin of another program (program A -> [stdin]program B) vvaidyan High Level Programming 1 04-30-2008 01:44 PM
executing a program within a program Gekko High Level Programming 4 06-27-2002 03:36 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-18-2009
awkliker awkliker is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 6
AWK program

Hi all,

I have the following problem and hope someone could help me.

I have 184 files, each with 5 columns (c1, c2, c3, c4, c5). I am only interrested in column 5, and would like to paste column 5 from all the 184 files into one file. I have tried the following with two files

awk '{print $5)' file1 file2 | paste -d" " >! a06.txt

The above command line does work, but it pastes colum 5 in one column in the new file (a06.txt). I want it to do it side by side, i.e. c5file1 c5file2, instead of c5file1
c5file2
At the end, I expect to have a file with c5file2 c5file2 c5file3....c5file184.

Thanks for your help!
  #2 (permalink)  
Old 03-18-2009
wabard wabard is offline
Registered User
  
 

Join Date: Mar 2009
Location: Adelaide, SA & Perth, WA - Australia
Posts: 25
You have posted this request in the incorrect area of the forums. I'll think about the solution and get back to you once a moderator has moved the thread.
  #3 (permalink)  
Old 03-18-2009
awkliker awkliker is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 6
Thanks!

I am new to the forum, and could not figure out where to add new post.

awkliker
  #4 (permalink)  
Old 03-18-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,382
thread moved

Quote:
Originally Posted by wabard View Post
You have posted this request in the incorrect area of the forums. I'll think about the solution and get back to you once a moderator has moved the thread.
thread moved!!!
  #5 (permalink)  
Old 03-18-2009
achellstrom achellstrom is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 16
This smells like homework, but here is some of the answer. First I would set up a loop to go from 1...184 and dump the awk results to a file say 'result.txt'. Next I would use the paste command to put them in your desired format.
But for the way you have listed the problem here is the answer
awk '{print $5}' file1 ...... file184>result.txt;paste -s a06.txt
  #6 (permalink)  
Old 03-18-2009
achellstrom achellstrom is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 16
Sorry it is late here. I made a typo. Here is the answer
awk '{print $5}' file1 ...... file184>result.txt;paste -s result.txt > a06.txt
  #7 (permalink)  
Old 03-18-2009
aaaaargh aaaaargh is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 20
not tested but I would would

Code:
awk '{print $5}' file* >> result.txt

What is the "desired" format?
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 08:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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