In file two.txt
i have to look for pattern which column one "ONS...."of file "one.txt" and want to make one file(either new or update one.txt) with merge o/p. for example
note that this ^ is a nested display, in fact it correspond to the default separator of paste (here <tab> key so since it is considered as special char to enter, i had to use <Ctrl>+<V> keys and then <tab> key
@ ctsgnb
Dear, this is murging both the line . Thanks for ur help here.
ONS.1287677000.820.log 20Oct2010 ONS.1287677000.820.log:V[4.1.2] AC[ONS] CC[73] EN[]
ONS.1287677000.123.log 21Oct2010 ONS.1287677000.123.log:V[4.1.2] AC[ONS] CC[73] EN[]
@ vgersh99
Sir, comand mentioned by u not working , facing error while executing
nawk 'FNR==NR{f1[$1]=$2;next} $1 in f1 {$2=f1[$1] FS $2;print}' one.txt FS=: two.txt
awk: 0602-533 Cannot find or open file one.txt.
The source line number is 1.
Why do you think this is?
In your original post you quoted 2 files: one.txt and two.txt
Do you have these files? Are they named one.txt and two.txt as posted by you?
If my code just merge the files, then it means that you have to reconsider the way you entered the sed statement.
Indeed, as shown in my example, it should remove the unwanted ONS*log
If your default separator for paste command is a space instead of a tab, just change it into the sed statement
so instead of
paste 1.txt 2.txt | sed 's|<Ctrl>+<V><tab>.*:|:|'
you would have :
paste 1.txt 2.txt | sed 's|<space>.*:|:|'
of course the <key> stand for the button you'd press
so on your screen :
paste 1.txt 2.txt | sed 's| .*:|:|'
otherwise, you can try this ?
paste 1.txt 2.txt | sed 's|.ONS.[0-9]*.[0-9]*.log||'
or more simply
paste 1.txt 2.txt | sed 's|.ONS.*log||'
in this statement the dot "." before the ONS is what makes it match the second ONS.*log occurrence instead of the first one
Yep you true i have just tryied it : it does ..Lol
Since i get to use vi, i robotically used the <ctrl+v> <key> combination which worked as well but your true, for a better understanding for the reader, next time i will use the \t
o/p should be according to pattern("ONS.1287677000.820" and ONS.1287677000.123 in above file.)
need to merge date("20Oct2010") either in middle, or at start or at the end of each line("ONS.1287677000.820.log:V[4.1.2] AC[ONS] CC[73] EN[]"), but according to pattern mean file two.txt look for pattern in file one.txt and then merge according to that.
one form of output
ONS.1287677000.820.log:V[4.1.2] AC[ONS] CC[73] EN[]:V[4.1] 20Oct2010
ONS.1287677000.123.log:V[4.1.2] AC[ONS] CC[73] EN[]:V[4.1] 21Oct2010
ONS.1287677000.820.log:V[4.1.2] AC[ONS] CC[73] EN[]:V[4.1] 20Oct2010
but let say if two.txt have two rows and one.txt has 3 rows,then also it will show o/p acc to 2 lines present in two.txt.
Please advice as all of above not giving expected o/p.