New answers tagged


There are carriage returns at the end of $i, because there are carriage returns at the end of the lines in all.txt. It was probably produced on Windows: Windows uses the two-character sequence CR,LF to mark a line break, whereas Unix (and most of the rest of the world) uses just LF (linefeed, synonym of newline in the Unix world), so Unix sees a line with a ...


Your error message indicates that sed is getting an argument of /log.dat - neither $i or $in are set to any value. I think you have a blank line in your All.txt file. /log.dat: No such file or directory #(then the path to this file)


The read isn't wrong but you are interpreting the results slightly wrongly. The EOL marker is \n, so entering that character means that read has encountered a "line" that has no characters. Note that the variable $c doesn't contain the \n: while IFS= read -r c do test -z "$c" && echo "Zero length string" || echo "I read '$c'" done By adding ...


first your printf function works perfectly $ export c=" " $ LC_CTYPE=C printf "%d\n" "'$c" 32 But running the script line with -vx on shows that the data getting to this line is wrong ( I won't paste this output ) So I figure it is the read that is wrong. The default EOL delimiter for read is newline, so I tried altering that. This seems to work while ...

Top 50 recent answers are included