Skip to main content

Timeline for echo string >> file does not work

Current License: CC BY-SA 3.0

13 events
when toggle format what by license comment
Mar 2, 2013 at 3:29 comment added Karthick S I tried redirecting the output to a different directory and it is working fine. Seems to be something about this directory? Here are the permissions on this directory: drwxr-xr-x Doesn't seem wrong to me. Any ideas?
Mar 2, 2013 at 3:27 comment added Karthick S Tried with set -x the code is going into the loop and the echo is also being executed. In fact, when I remove the redirection, I am able to see the output on the screen.
Mar 2, 2013 at 2:03 comment added Gilles 'SO- stop being evil' Add set -x at the head of the script just below the #!/bin/bash line) to see a trace of what the script is doing.
Mar 1, 2013 at 18:33 answer added rmacduff timeline score: 0
Mar 1, 2013 at 15:14 comment added Stéphane Chazelas I mean the script itself contains CRs
Mar 1, 2013 at 14:41 comment added Karthick S Stephane, my script does not use any input files. All the values required (IN_REGEX, OUT_REGEX and OUTPUT_FILE) are set in the script itself. There seems to be something that is preventing this script from writing to the filesystem. I have checked the permissions, the space availability and also if touch works. All three don't show any problem.
Mar 1, 2013 at 13:35 comment added Stéphane Chazelas From your two recent questions, I'd bet your script has some carriage return characters as if coming from a system where line ending is with CRLF. Try dos2unix or d2u on the files to convert to Unix line ending. See the output of cat -vte on the file to confirm.
Mar 1, 2013 at 13:30 history tweeted twitter.com/#!/StackUnix/status/307482977963741184
Mar 1, 2013 at 12:53 comment added Karthick S Ashwin, even a normal touch is working. Did not need a sudo
Mar 1, 2013 at 12:47 comment added bagavadhar maybe you dont have permission on the dir to redirect the file. So you maybe running it as sudo. sudo touch will work. but sudo echo "string" >> log.txt wont work. Can you add the permission in that dir to the question and how you are running the script.
Mar 1, 2013 at 12:44 answer added vonbrand timeline score: 3
Mar 1, 2013 at 12:37 comment added ott-- Can you move the >>$OUTPUT_FILE to the end of the loop, i.e. done >>$OUTPUT_FILE?
Mar 1, 2013 at 12:14 history asked Karthick S CC BY-SA 3.0