Your version of tail may require a '-n' option, that is: tail -n +3 file2
Regards, - Robert On Mon, Jan 4, 2021 at 12:18 PM alig...@gmail.com <aligam...@gmail.com> wrote: > Thanks for your help, but tail +3 appears an error as > > $ tail: cannot open '+3' for reading: No such file or directory > > On Monday, January 4, 2021 at 8:31:44 PM UTC+2 Robert Citek wrote: > >> >> Input files: >> >> $ cat file1 >> da1 >> da2 >> da3 >> >> $ cat file2 >> cx1 >> cx2 >> cx3 >> cx4 >> >> Pick just the lines you want from each file: >> >> $ head -2 file2 >> cx1 >> cx2 >> >> $ sed -n 2p file1 >> da2 >> >> $ tail +3 file2 >> cx3 >> cx4 >> >> Stitch the commands together with braces to achieve your output: >> >> $ { >> head -2 file2 >> sed -n 2p file1 >> tail +3 file2 >> >> } >> cx1 >> cx2 >> da2 >> cx3 >> cx4 >> >> >> Regards, >> - Robert >> >> On Mon, Jan 4, 2021 at 11:07 AM alig...@gmail.com <alig...@gmail.com> >> wrote: >> >>> file 1 contains >>> >>> da1 >>> da2 >>> da3 >>> >>> file 2 contains >>> >>> cx1 >>> cx2 >>> cx3 >>> cx4 >>> >>> I want to copy da2 after cx2, I want output will be >>> >>> cx1 >>> cx2 >>> da2 >>> cx3 >>> cx4 >>> >>> >>> On Monday, January 4, 2021 at 8:03:40 PM UTC+2 Robert Citek wrote: >>> >>>> Hmm. That sounds similar, but not identical to your original post. Can >>>> you clarify your question by giving an example, using a small dataset for >>>> both input and expected output? - Robert >>>> >>>> On Mon, Jan 4, 2021 at 10:44 AM alig...@gmail.com <alig...@gmail.com> >>>> wrote: >>>> >>>>> Hi Robert, >>>>> >>>>> I want to copy line 5 from a file to line 3 in another file >>>>> >>>>> Thanks in advance >>>>> On Monday, January 4, 2021 at 5:51:31 PM UTC+2 Robert Citek wrote: >>>>> >>>>>> Without example data, it's not completely clear what you are trying >>>>>> to do. But this might be one of many ways to accomplish what you are >>>>>> trying to do: >>>>>> >>>>>> $ { head -4 test.dat ; sed -n 3p w.dat ; tail -n +5 test.dat ; } | >>>>>> cat -n >>>>>> 1 b1 >>>>>> 2 b2 >>>>>> 3 b3 >>>>>> 4 b4 >>>>>> 5 a3 >>>>>> 6 b5 >>>>>> 7 b6 >>>>>> 8 b7 >>>>>> 9 b8 >>>>>> 10 b9 >>>>>> 11 b10 >>>>>> >>>>>> Sample data: >>>>>> >>>>>> $ paste w.dat test.dat | cat -n >>>>>> 1 a1 b1 >>>>>> 2 a2 b2 >>>>>> 3 a3 b3 >>>>>> 4 a4 b4 >>>>>> 5 a5 b5 >>>>>> 6 a6 b6 >>>>>> 7 a7 b7 >>>>>> 8 a8 b8 >>>>>> 9 a9 b9 >>>>>> 10 a10 b10 >>>>>> >>>>>> Regards, >>>>>> - Robert >>>>>> >>>>>> On Mon, Jan 4, 2021 at 8:02 AM alig...@gmail.com <alig...@gmail.com> >>>>>> wrote: >>>>>> >>>>>>> Hi, >>>>>>> I want to copy a line from a file to a specific line number in a >>>>>>> file. >>>>>>> >>>>>>> I copy line 3 from w.dat file to test.dat file using >>>>>>> >>>>>>> sed -n 3P w.dat >> test.dat >>>>>>> >>>>>>> but it copy line 3 to the end of test.dat file, I want copy line 3 >>>>>>> to line number 5 in the test.dat file, how can I do that? >>>>>>> >>>>>>> >>>>>>> -- >>>>> -- >>>>> You received this message because you are subscribed to the Linux >>>>> Users Group. >>>>> To post a message, send email to linuxus...@googlegroups.com >>>>> To unsubscribe, send email to linuxusersgro...@googlegroups.com >>>>> For more options, visit our group at >>>>> http://groups.google.com/group/linuxusersgroup >>>>> References can be found at: http://goo.gl/anqri >>>>> Please remember to abide by our list rules ( >>>>> http://tinyurl.com/LUG-Rules) >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Linux Users Group" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to linuxusersgro...@googlegroups.com. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/linuxusersgroup/39b6524a-fa47-4a91-8c66-93bd19393e62n%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/linuxusersgroup/39b6524a-fa47-4a91-8c66-93bd19393e62n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>> -- >>> You received this message because you are subscribed to the Linux Users >>> Group. >>> To post a message, send email to linuxus...@googlegroups.com >>> To unsubscribe, send email to linuxusersgro...@googlegroups.com >>> For more options, visit our group at >>> http://groups.google.com/group/linuxusersgroup >>> References can be found at: http://goo.gl/anqri >>> Please remember to abide by our list rules (http://tinyurl.com/LUG-Rules >>> ) >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "Linux Users Group" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to linuxusersgro...@googlegroups.com. >>> >> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/linuxusersgroup/66073c9a-2082-47c1-a2f2-d4d352fab537n%40googlegroups.com >>> <https://groups.google.com/d/msgid/linuxusersgroup/66073c9a-2082-47c1-a2f2-d4d352fab537n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > -- > You received this message because you are subscribed to the Linux Users > Group. > To post a message, send email to linuxusersgroup@googlegroups.com > To unsubscribe, send email to linuxusersgroup+unsubscr...@googlegroups.com > For more options, visit our group at > http://groups.google.com/group/linuxusersgroup > References can be found at: http://goo.gl/anqri > Please remember to abide by our list rules (http://tinyurl.com/LUG-Rules) > --- > You received this message because you are subscribed to the Google Groups > "Linux Users Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to linuxusersgroup+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/linuxusersgroup/6d401d19-f638-40ac-99f5-803c8b5ec7abn%40googlegroups.com > <https://groups.google.com/d/msgid/linuxusersgroup/6d401d19-f638-40ac-99f5-803c8b5ec7abn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -- You received this message because you are subscribed to the Linux Users Group. To post a message, send email to linuxusersgroup@googlegroups.com To unsubscribe, send email to linuxusersgroup+unsubscr...@googlegroups.com For more options, visit our group at http://groups.google.com/group/linuxusersgroup References can be found at: http://goo.gl/anqri Please remember to abide by our list rules (http://tinyurl.com/LUG-Rules) --- You received this message because you are subscribed to the Google Groups "Linux Users Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to linuxusersgroup+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/linuxusersgroup/CAKFjdm7N-b_-L2zAF0JkoiAGiCOgVYhLfV%2B1b2LD3a8ND0KX%2BQ%40mail.gmail.com.