LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-09-2007, 06:22 PM   #1
Four
Member
 
Registered: Aug 2005
Posts: 298

Rep: Reputation: 30
simple console commands


Hi,

I would like to do the following

cat somefile | m4 > somefile

The idea is to take somefile and process it with m4 and just replace it with somefile. I have alot of files I want to be processed by m4. Is it possible to do it all in oneline instead of doing line by line?

And is it possible to make a simple function in the console just for one time use in linux?

Thanks
 
Old 03-09-2007, 06:40 PM   #2
dannystaple
Member
 
Registered: Apr 2006
Location: London, Uk
Distribution: Ubuntu on Desktop
Posts: 121

Rep: Reputation: 15
Quote:
Originally Posted by Four
Hi,

I would like to do the following

cat somefile | m4 > somefile

The idea is to take somefile and process it with m4 and just replace it with somefile. I have alot of files I want to be processed by m4. Is it possible to do it all in oneline instead of doing line by line?

And is it possible to make a simple function in the console just for one time use in linux?

Thanks
If you have many files, and you are going to want to do it again, how about using a makefile with a rule to process it:
makefile:
Code:
FILES=a b c d e f g

all: $(foreach file, $(FILES), $file.out)

%.out:%
  m4 $* >$*.out
Then a simple "make" should do it. You will have to adapt ".out" to the extension you want for it. This comes with the advantage that if you change one file, you can run this again, and it will only update for the file that changed. I am sure this is probably not the best solution, but being more familiar with dev tools than straight shell scripting I nearly always dive for a make file or perl script.

Danny
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Console (terminal) Commands ? sonsuzuncu Linux - Newbie 3 10-27-2005 06:31 PM
Simple Commands jackel Linux - Newbie 3 04-13-2004 11:43 PM
Disabling console commands? Kage Linux - Newbie 4 02-09-2002 12:38 PM
Console Commands. Madmanator Linux - General 1 01-24-2002 02:10 PM
aliasing commands in the console? phishead Linux - General 2 01-09-2002 09:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:21 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration