Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sending 'command line' to a file

Posted on 2001-08-08
9
Medium Priority
?
285 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
Industry Leaders: 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 80 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

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!

Question has a verified solution.

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

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…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.
Suggested Courses

609 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