Hi, I want to redirect the output of the 'ls' command into a file. For example "ls -Fa | ./newfile.text"
However I am getting the 'permission denied' error. Am I going about this the correct way?
Hi, I want to redirect the output of the 'ls' command into a file. For example "ls -Fa | ./newfile.text"
However I am getting the 'permission denied' error. Am I going about this the correct way?
Well this is not the right place for this question but I think you want something like:
ls -Fa > newfile.text
Without more specifics that is the best I can suggest....
Thanks for the reply. I just realized that 'redirecting' is possibly the wrong word to use for the | symbol. Anyway I 'd like to stick to using '|' . Any advice would be helpful, thanks
You can't do that because:
1) You are trying to stream the output through a pipe, which is not quite the same as simple redirection.
2) There is no process on the other end of the pipe -- there is a non-executable file, hence "permission is denied".
Hopefully you understand *nix file modes. These are set/read as a mask. The first part of the mask refers to the owner, the 2nd to the owner's group, the third to everyone else. The mask is:
1: executable
2: writable
4: readable
So 6 means read/write permission (4+2). 640 would mean the owner can read/write the file, the owner's group can read the file, and everyone else has no access to the file.
Text files are usually set some combination of 6 4 and 0 because you do not execute a text file (executable scripts excepted). So if you try and execute a text file set 666 -- which means anyone can read or write it -- you will get permission denied, because the executable "bit" (1) is not set.
Executables are usually set 7 or 5 (read + write + execute, or read + execute). 1 (execute only) is oxymoronic because a file must be read to be executed.
But you do not want to execute newfile.text anyway, you want to write the output of ls into it. For that use:
ls > newfile.text
Notice, redirection uses >, not |. | is a pipe.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Perhaps if you:
1. Moved this to the Linux subforum here and...
2. Explained what you are *really* trying to do...
You might get some help...
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
As jeffcobb stated previously, please ask these questions on a Linux/Shell forum.
This is an excellent one: Shell Programming and Scripting - The UNIX and Linux Forums