Solved

sending 'command line' to a file

Posted on 2001-08-08
9
272 Views
Last Modified: 2010-04-21
When I say

cat pnm.txt > trace.txt

It sends output of  the command to a file trace.txt.
is there any way to send the command
'cat pnm.txt'
to a file. ?

0
Comment
Question by:prashant_n_mhatre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 6

Expert Comment

by:bira
ID: 6365462
Hi

   echo "cat pnm.txt" > file.txt

   will create a file named file.txt with the
  contents "cat pnm.txt"



0
 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6365525
bira:

Thanks for your suggestion. I already know that. I'm looking for some way by which I'll be able to execute the command as well as spool it to a file.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6365692
csh% cat pnm.txt |& tee trace.txt
ksh% cat pnm.txt 2>&1 | tee trace.txt
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6365786
On ksh
It sends the output of 'cat pnm.txt' to the file trace.txt.
It doesn't send "cat pnm.txt" to the trace.txt
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 20 total points
ID: 6365916
hmm, do you need:
   echo "cat pnm.txt"|awk '{printf "echo %s >trace.txt\n",$0; print $0;}'|sh
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 6365921
what about
echo "cat pnm.txt" > trace.txt
cat pnm.txt >> trace.txt
 
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6365925
BTW, >> instead of > might also be a choice ;-)
0
 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6367983
Thanks all !!!

I didn't find the exact solution what I was looking for. I guess unix doesn't provide such simple option.

"ahoffmann"'s answer is more close to what I was looking for.

0
 
LVL 4

Author Comment

by:prashant_n_mhatre
ID: 6367986
Thanks all !!!

I didn't find the exact solution what I was looking for. I guess unix doesn't provide such simple option.

"ahoffmann"'s answer is more close to what I was looking for.

0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question