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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
catitself does not write to file, only to stdout. The shell redirect>does the writing.The problem with your statement is that
cattakes list of file names as parameter, socat $variablewill attempt to print the contents of a file whose name is stored in$variablewhich most likely doesn’t exist.To write the contents of the variable to a file, use
echo $variable >t.h