LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-30-2006, 07:42 PM   #1
johndoe0028
Member
 
Registered: Jun 2005
Location: CA, USA
Distribution: Gentoo
Posts: 165

Rep: Reputation: 30
Perform an operation on files x, y...direct output to x.out, y.out respectively


Ok, the title may be a bit confusing; so here's what I want to do. I want to take a bunch of files, let's call them x, y and z. I want to perform an operation on them, and direct the output to text files: x.out, y.out and z.out, respectively. In reality, I have 512 files that I want to operate on.

How would I go about doing this?

If there's anything else I need to provide, please tell me. Thanks.

Last edited by johndoe0028; 03-30-2006 at 07:44 PM.
 
Old 03-31-2006, 01:16 AM   #2
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Assuming you perform the exact same process on each file and in the same directory:

Code:
for f in *
do
some-process $f > $f.out
done
This is basic sh syntax, e.g. bash or zsh

Last edited by vls; 03-31-2006 at 01:26 AM.
 
Old 03-31-2006, 06:52 PM   #3
johndoe0028
Member
 
Registered: Jun 2005
Location: CA, USA
Distribution: Gentoo
Posts: 165

Original Poster
Rep: Reputation: 30
Thank you very much; it worked perfectly.
 
Old 03-31-2006, 11:01 PM   #4
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Quote:
Originally Posted by johndoe0028
Thank you very much; it worked perfectly.
But do you know why it worked perfectly? That's the next step.
 
Old 04-01-2006, 03:30 AM   #5
johndoe0028
Member
 
Registered: Jun 2005
Location: CA, USA
Distribution: Gentoo
Posts: 165

Original Poster
Rep: Reputation: 30
Yes, call the input file 'f', a variable. Run the process on * (all files) and direct the output to a text file(name-of-input.out). Finish.

I just didn't know how to tackle that one.
 
Old 04-02-2006, 01:59 PM   #6
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Sorry to be overly pedantic. I meant to put a smiley in there.
 
Old 04-02-2006, 11:39 PM   #7
johndoe0028
Member
 
Registered: Jun 2005
Location: CA, USA
Distribution: Gentoo
Posts: 165

Original Poster
Rep: Reputation: 30
'Tis fine; don't woory about it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to perform an action (a command) on multiple files with the FOR loop? chun-mee Programming 4 08-23-2005 04:11 AM
How to direct output both log file and to terminal... freebies Linux - General 1 02-25-2005 07:32 AM
Returned mail: Can't create output: Operation not permitted turbo_acura Linux - General 0 10-19-2004 07:56 AM
How to direct output from make to a file? DDD25 Programming 6 07-25-2004 06:55 AM
Best way to ALOT of files in a direct to other direct? packman Linux - General 2 10-21-2002 08:31 PM


All times are GMT -5. The time now is 06:15 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration