![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| strange behavior of find with xargs | jerardfjay | Shell Programming and Scripting | 9 | 08-09-2007 09:06 AM |
| Very Strange Behavior for redirection | cahook | Shell Programming and Scripting | 5 | 08-08-2007 12:32 PM |
| Strange Real Memory usage behavior | Skyybugg | AIX | 5 | 05-31-2007 11:17 AM |
| Strange Behavior on COM2 | Elwood51 | UNIX for Dummies Questions & Answers | 0 | 08-02-2006 04:31 PM |
| Strange behavior from 'read' statements. (ksh - but could be same on other shells) | alexop | Shell Programming and Scripting | 5 | 05-02-2006 12:14 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
strange sed behavior
I have a file called products.kp which contains, for example,
12345678,1^M 87654321,2^M 13579123,3 when I run the command cat products.kp| sed -f kp.sed where kp.sed contains s,^M,, I get the output 12345678,1 87654321,2 13579123,3 so everything is ok. However, when I run this command on another unix box, I get the output 12345678,1 87654321,2 ie. I don't get the last line returned. has anyone any idea why? or a different way to do it in sed? Thanks ps. I'm using Sco and Bourne shell |
|
||||
|
Thanks,
the file does always have a missing ^M on the last line. Is there any way I can get around this? To give you a brief outline, the suppliers of the package that produces this file for our system have done a new release which produces the file as described (whereas it used to have a ^M on every line). On our system, which is released across 220 unix boxes, I run the 'sed -f kp.sed' command, so the only thing I can realistically change is the contents of kp.sed (maybe to append a ^M to every line then substitute it for '' ?) or am I done for & will just have to wait for their fix to their system? |
|
|||||
|
I'm not really following you, but here are some comments that might clear up some confusion.
A control M in not a newline character. Control M's are not required in a line. If you have a text file that is missing the last newline character, you can append one with: echo >> file How many lines does "wc -l" find in your file? To get rid of Control M's, you may have a program called dos2unix. You can also use "tr -d". And there are other solution that have been mentioned before as a substitute for dos2unix. You might try our search function since they have been mentioned before. |
|
||||
|
I've sorted it now, I ended up using dtox & then echoing it to a file like you suggested. This sort of thing
>$1.okp dtox $1.kp > $1.dtox for line in `cat $1.dtox` do echo $line >> $1.okp done Have to release a patch over 220 boxes now though! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|