Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have the output of the crontab -l stored in a file (crontab_file) with no extension. But whenever I try to cat it, I get errors saying command not found for multiple line of the file. Here is the code I have so far:

file/commands/crontab_file > $PWD/tmp
cat $PWD/tmp

I keep getting an error and I don't know why (maybe since I am a beginner). Any suggestions?

share|improve this question
5  
Whenever you post because you "keep getting an error," it would greatly help to include the error you keep getting in your post. –  Kevin Jun 16 at 20:23

1 Answer 1

up vote 6 down vote accepted

The code in your post will execute the file file/commands/crontab_file and redirect the standard output to the file $PWD/tmp. When you cat that file you are seeing the output of the execution of the script you called, which was written to that file. If you want to cat the crontab file, just do it directly cat file/commands/crontab_file.

share|improve this answer
2  
+1 To clarify slightly: > executes the file on the left hand side -- it does not copy it. Since the file wasn't intended to be executed, this produces a list of errors, and that's what's in $PWD/tmp. –  goldilocks Jun 16 at 20:17
1  
Strange that the errors end up in the tmp file, as errors should be on stderr, not stdout. Also strange that the crontab_file file was set to executable. –  richard Jun 16 at 21:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.