The UNIX and Linux Forums  

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
How to chk the file name using wildcards?? RRVARMA Shell Programming and Scripting 7 07-10-2008 08:23 AM
Separate based on file names prashk15 Shell Programming and Scripting 2 02-04-2008 05:37 AM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 01:25 AM
File names giantflameeater UNIX for Dummies Questions & Answers 9 11-24-2004 03:03 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-29-2008
Registered User
 

Join Date: Jan 2008
Posts: 1
Stumble this Post!
File names based off of wildcards

Hello all-

First post, so just to forewarn you: I know enough about Perl and the Terminal to get myself into trouble, not quite enough to always get out.

I'd like to know if it is possible to, from the command prompt, use a wild-card to declare the names of files for input and then use the value of the wild card in the same line to declare the name for the output. I'm using the BLAST package to search through genes, so what I'd like to have is:

% blastall -p blastn -i *.dna -o (some-variable).output

The -p calls the blastn part of the package, the -i declares the input to be all the genes in the directory and the -o declares the output. I'd like it if a geneA.dna file, for instance, produced an output file called geneA.output.

It strikes me as one of those glaringly obvious things I've overlooked at some point, but I have no idea what could be put in the (some-variable) portion of the command. Gory details: using the public BLAST package (so I can't edit anything within there easily to... at all), executing on a Mac OS X Terminal session. If you need any other details, please let me know.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-30-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 709
Stumble this Post!
Post

Very do-able but not as easily as you'd hope:
Code:
for file in *.dna; do blastall -p blastn -i $file -o ${file}.output
Will produce a bunch of files *.dna.output
To get *.output:
Code:
for file in *.dna; do blastall -p blastn -i $file -o `echo $file | sed 's/dna$//'`.output
Incidentally, windows actually lets you do something like this:
Code:
blastall -p blastn -i *.dna -o *.output
But only for certain commands - it seems to depend on how you hold your mouth when you do it.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0