LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 02: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, 03:27 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,879

Rep: Reputation: 2190Reputation: 2190Reputation: 2190Reputation: 2190Reputation: 2190Reputation: 2190Reputation: 2190Reputation: 2190Reputation: 2190Reputation: 2190Reputation: 2190
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, 10:55 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,544

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

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

man awk


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

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
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 06: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 01:58 PM
[SOLVED] Insert line using sed or awk at line using line number as variable sunilsagar Programming 11 02-03-2012 10:48 AM
replace specific character after specific line by awk Syed Tarique Moin Programming 2 07-19-2010 01:47 PM
Editing a specific group of lines by line number? SirTristan Linux - Newbie 5 09-29-2009 07:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:16 PM.

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