?
Solved

sending 'command line' to a file

Posted on 2001-08-08
9
Medium Priority
?
278 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
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.
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

752 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