[SOLVED] awk does not print the value of the variable as I expected, please help
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If the data was created in Windows there could be a carriage return character at the end of each line.
The first ^C line has 28 characters so substr($0,1,28) omits the carriage return.
The next ^C lines have only 24 characters so substr($0,1,28) includes the carriage return.
Carriage returns can be removed from the file with GNU sed