cat is not writing to a file?
سؤال
i want to write to a file by cat command.
cat $variable >t.h
while it is not writing to the file. The file is empty anyway. why is cat not writing to the file?
المحلول
cat
itself does not write to file, only to stdout. The shell redirect >
does the writing.
The problem with your statement is that cat
takes list of file names as parameter, so cat $variable
will attempt to print the contents of a file whose name is stored in $variable
which most likely doesn't exist.
To write the contents of the variable to a file, use echo $variable >t.h
لا تنتمي إلى StackOverflow