There are few lines of data which needs to be append to the previous line. That is, the line should commence by a 7 or 8 digit number.
When i see the hex format of file (od -x file 1 ) , it contains 0d 0a. I want it to be only 0d. dos2unix wasn't much of a help. Appreciate your help. thanks
oops i read your second reply after posting this !! still you can go through this reply
--------------------------------------------------------------------------------
0d 0a - Hex representation of Control-M character / <C-R> / /r/n
I faced same kind of problem where i had to remove only /r & keep /n. if its only1 time thing then open file in vim
# In command mode
:se list # list all characters
:se ff=unix # set file format to unix, will remove /r from /r/n
:w! # save the file
:se ff? # verify file format
or
perl -pi.back -e "s/\x0d0a/\x0a/g" <file_name>
above should do the trick, i did something like that but i can not recall it completely you can play with above perl expression see if it work! BTW take a backup of file in some other directory before you run this.
Hi guys, thanks a lot for your response. Let me tell you the complete requirement:
File 1:
111,10
112,20
113,30
114,40
File 2:
111,51,jklfsdfj
dkfld
111,52,dadfdl das
112,53,ewuei ewi ewop
wqopie ew
112,54,aaa aa[1] qq
113,55,ee ee[4] rr[6]
ew 1
ewe 4
My task is to produce the output as:
10 jklfsdfj dkfld dadfdl das
20 ewuei ewi ewop wqopie ew aaa aa[1] qq
30 ee ee[4] rr[6] ew 1 ewe 4
That is, whenever column1 of file1 matches with column1 of file2,
output has to be column2 of file1 and column3 of file2 corresponding to this match.
Hence I used join. Like this:
join -1 1 -2 1 -o 1.2 2.3 file1 file2 >file3
But the output is errorneous since file2 has data not in a pattern.
@ludwig : thank you. But i need the code in shell scripting.
Please show carriage-return and line-feed characters in the before and after examples. If you are dealing with a non-unix format text file it will require special techniques.
@m.d.ludwig
Hmm. I specialise in data conversion.
Unfortunately the O/P has not revealed the file format, the Operating System or any consistent data samples.
This thread is going nowhere fast.