LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 07-20-2016, 03:57 AM   #1
darik2
LQ Newbie
 
Registered: Jul 2016
Posts: 1

Rep: Reputation: Disabled
Insert a lines at specific line number with awk


Hello I am trying to use awk to do this.

File1

1Linux aaa aaaa
2Solaris bb bbb
3Cygwin cccc cc
4Ubuntu dd dddd
5Fedora ee eeee
6Aix fff fff
7Hpux gggg gg


File2

We were born, in the earth, beyond the land

Output file

1Linux aaa aaaa
2Solaris bb bbb
We were born
3Cygwin cccc cc
4Ubuntu dd dddd
in the earth
5Fedora ee eeee
6Aix fff fff
beyond the land
7Hpux gggg gg


How do I do this?
Thank you in advance for your help.
 
Old 07-20-2016, 04:27 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,928

Rep: Reputation: 1865Reputation: 1865Reputation: 1865Reputation: 1865Reputation: 1865Reputation: 1865Reputation: 1865Reputation: 1865Reputation: 1865Reputation: 1865Reputation: 1865
You do it by making an effort.
When you have done so and failed, examine why it failed to do as you wanted. Then ask for help, showing your work.
 
Old 07-20-2016, 11:55 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,331

Rep: Reputation: 2770Reputation: 2770Reputation: 2770Reputation: 2770Reputation: 2770Reputation: 2770Reputation: 2770Reputation: 2770Reputation: 2770Reputation: 2770Reputation: 2770
Agreed ... at least make some attempt
 
Old 07-21-2016, 02:06 AM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,105

Rep: Reputation: 181Reputation: 181
type this at the terminal:

man awk


info printf
 
Old 07-23-2016, 09:15 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,636

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
You might actually find it easier using ex (alternate name used for vim that uses a command line syntax for editing).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert multiple lines in specificic position with sed or awk micronemo Linux - Newbie 4 09-13-2012 07:27 AM
[SOLVED] bash: sort lines in 2 files so that equal lines are at the same line number... masavini Programming 10 06-21-2012 02:58 PM
[SOLVED] Insert line using sed or awk at line using line number as variable sunilsagar Programming 11 02-03-2012 11:48 AM
replace specific character after specific line by awk Syed Tarique Moin Programming 2 07-19-2010 02:47 PM
Editing a specific group of lines by line number? SirTristan Linux - Newbie 5 09-29-2009 08:30 PM


All times are GMT -5. The time now is 11:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration