Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

sending 'command line' to a file

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
prashant_n_mhatre
Asked:
prashant_n_mhatre
1 Solution
 
biraCommented:
Hi

   echo "cat pnm.txt" > file.txt

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



0
 
prashant_n_mhatreAuthor Commented:
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
 
ahoffmannCommented:
csh% cat pnm.txt |& tee trace.txt
ksh% cat pnm.txt 2>&1 | tee trace.txt
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
prashant_n_mhatreAuthor Commented:
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
 
ahoffmannCommented:
hmm, do you need:
   echo "cat pnm.txt"|awk '{printf "echo %s >trace.txt\n",$0; print $0;}'|sh
0
 
vinnyd79Commented:
what about
echo "cat pnm.txt" > trace.txt
cat pnm.txt >> trace.txt
 
0
 
ahoffmannCommented:
BTW, >> instead of > might also be a choice ;-)
0
 
prashant_n_mhatreAuthor Commented:
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
 
prashant_n_mhatreAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now