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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
command line args 2 skooly5 UNIX for Dummies Questions & Answers 2 04-06-2008 09:36 PM
command line args skooly5 UNIX for Dummies Questions & Answers 2 04-06-2008 07:46 PM
Command line args enuenu High Level Programming 2 05-29-2007 12:19 AM
alias with args how to ... umen UNIX for Dummies Questions & Answers 4 12-28-2005 07:47 AM
Args to Array Shaz Shell Programming and Scripting 2 06-30-2003 04:11 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 11-17-2008
lost lost is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 24
args of 50+ files

Hey..
I've gotten inspired by another thread and used this:
#!/usr/bin/bash
args 2,5 $(<file.list)
It works but I'll like the results separated into different files or back into the 'used'/original files, whatever is easiest.
e.g. use fileA | args 2,5 > fileB or fileA and then do this to 50 files (I thought the idea with the list of files to be handy).
Is there an easy way?
Thanks!
  #2 (permalink)  
Old 11-18-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,715
Maybe I have not had my coffee yet, but I do not get what you want.
What is args - a script you wrote?
  #3 (permalink)  
Old 11-18-2008
lost lost is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 24
Sorry. Forgot that args is only on our 'server'. Yes, it's a script that 'takes' the stated arguments in the given line/file.
In this case it 'takes' argument 2 and 5 and paste them.
Basicly what I need to do is to 'take' two columns out of a file and repeat that for 50 files.
Please let me know if I still don't make sense..
Thanks!
  #4 (permalink)  
Old 11-18-2008
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 704
Hi.
Quote:
Originally Posted by lost View Post
... what I need to do is to 'take' two columns out of a file and repeat that for 50 files ..
The best way to avoid ambiguity and misunderstanding is for you to provide a sample of the data and your expected output.

Please remember to place your posted data in CODE markups -- highlight the data lines with your mouse, then click the # button above the editing window ... cheers, drl

Last edited by drl; 11-18-2008 at 09:00 PM..
  #5 (permalink)  
Old 11-19-2008
lost lost is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 24
help wanted!!

OK.
This is what I have:
Code:
C 306 P  B 85 V 3.46
C 307 K  B 81 H 2.69
C 307 K  B 85 V 3.43
C 309 V  B 82 N 2.67
C 309 V  B 78 Y 3.23
C 309 V  B 81 H 3.42
C 311 Q  B 78 Y 3.46
And this is what I want:
Code:
306 85
307 81
307 85
309 82
309 78
309 81
311 78
And even better sorted this way:
Code:
306 85
307 81,85
309 82,78,81
311 78
Then I have to repeat it for 70+ files.
Hope it makes sense now.
Thanks for replying.

Last edited by lost; 11-19-2008 at 01:43 PM..
  #6 (permalink)  
Old 11-19-2008
rubin's Avatar
rubin rubin is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2007
Posts: 321
Quote:
Originally Posted by lost View Post
...
And even better sorted this way:
Code:
306 85
307 81,85
309 82,78,81
311 78
Then I have to repeat it for 70+ files.
Hope it makes sense now.
Thanks for replying.

Code:
awk '{printf ($2 in a) ? ","$5 : (NR>1) ? RS $2 FS $5 : $2 FS $5; a[$2]} END{print e}' file

Output:

Code:
306 85
307 81,85
309 82,78,81
311 78
Then you can use a for loop or find+while loop for all of your files.
  #7 (permalink)  
Old 11-20-2008
lost lost is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 24
YOU'RE A STAR!!!!!!!!
THANKS YOU SO MUCH!!!
yippiyeah.... yippiyeah..... ;D
Sorry I didn't get the thing with the for loop for the files, because how do I make the output from each file separated into individual files? Any way I'm so glad it works so even though it's stupid I can manually do the repeats for all the files...
Sponsored Links
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

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 01:26 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