LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-31-2013, 03:01 PM   #16
axl718
LQ Newbie
 
Registered: Apr 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled

Thanks I think that will work. Can you please change the 3rd line of file2 and the third line of your output to blah/home the other information I meant not to include.
 
Old 01-31-2013, 03:13 PM   #17
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,881

Rep: Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660
Quote:
Originally Posted by axl718 View Post
Thanks I think that will work. Can you please change the 3rd line of file2 and the third line of your output to blah/home the other information I meant not to include.
InFile2 ...
Code:
rwxrwxrwx 0/0 0 Dec 17 15:25 2002 ./
rwxrwxrwx 0/0 0 Dec 17 15:37 2002 ./blah/
rwxrwxr-x 0/3 0 Dec 17 15:37 2002 ./blah/home/
rwxrwxr-x 8654/8655 0 Dec 17 15:53 2002 ./blah/home/foo/
rw-rw-rw- 0/3 889 Jul 29 14:14 2002 ./blah/home/foo/hostlist
rwxrwxrwx 0/3 0 Dec 16 16:02 2002 ./comp0/
rwxrwxrwx 0/3 0 Dec 17 10:23 2002 ./comp0/etc/
rw-rw-rw- 0/3 477 Jul 29 14:14 2002 ./comp0/etc/tab
r--r--r-- 0/3 7329 Jul 29 14:14 2002 ./comp0/etc/bootinfo
rwxrwxrwx 0/3 0 Mar 26 11:07 2003 ./comp0/opt/
rwxrwxrwx 0/3 0 Mar 26 10:45 2003 ./comp0/opt/RARED/
rw-rw-r-- 0/0 133120 Dec 6 16:05 2002 ./comp0/opt/RARED/configs.tar
rwxrwxrwx 0/0 0 Dec 16 17:01 2002 ./comp1/
rwxrwxrwx 0/0 0 Dec 16 17:01 2002 ./comp1/etc/
r--r--r-- 0/0 5797 Dec 10 10:24 2002 ./comp1/etc/bootinfo
r--r--r-- 0/3 22483 Dec 16 15:25 2002 ./comp1/etc/hosts
r--r--r-- 0/3 22483 Dec 17 15:35 2002 ./comp1/etc/hosts
r--r--r-- 0/3 22483 Dec 18 15:45 2002 ./comp1/etc/hosts
r--r--r-- 0/3 22483 Dec 19 15:55 2002 ./comp1/etc/hosts
OutFile ...
Code:
rwxrwxrwx 0/0 0 Dec 17 15:25 2002 ./
rwxrwxrwx 0/0 0 Dec 17 15:37 2002 ./blah/
rwxrwxr-x 0/3 0 Dec 17 15:37 2002 ./blah/home/
rwxrwxr-x 8654/8655 0 Dec 17 15:53 2002 ./blah/home/foo/
rw-rw-rw- 0/3 889 Jul 29 14:14 2002 ./blah/home/foo/hostlist
rwxrwxrwx 0/3 0 Dec 16 16:02 2002 ./comp0/
rwxrwxrwx 0/3 0 Dec 17 10:23 2002 ./comp0/etc/
rw-rw-rw- 0/3 477 Jul 29 14:14 2002 ./comp0/etc/tab
r--r--r-- 0/3 7329 Jul 29 14:14 2002 ./comp0/etc/bootinfo
rwxrwxrwx 0/3 0 Mar 26 11:07 2003 ./comp0/opt/
rwxrwxrwx 0/3 0 Mar 26 10:45 2003 ./comp0/opt/RARED/
rw-rw-r-- 0/0 133120 Dec 6 16:05 2002 ./comp0/opt/RARED/configs.tar
rwxrwxrwx 0/0 0 Dec 16 17:01 2002 ./comp1/
rwxrwxrwx 0/0 0 Dec 16 17:01 2002 ./comp1/etc/
r--r--r-- 0/0 5797 Dec 10 10:24 2002 ./comp1/etc/bootinfo
r--r--r-- 0/3 22696 Jan 31 11:04 2013 ./comp1/etc/hosts
r--r--r-- 0/3 23035 Feb 01 10:28 2013 ./comp1/etc/hosts
r--r--r-- 0/3 22694 Feb 03 11:04 2013 ./comp1/etc/hosts
r--r--r-- 0/3 23033 Feb 05 10:28 2013 ./comp1/etc/hosts
Daniel B. Martin
 
Old 01-31-2013, 03:15 PM   #18
axl718
LQ Newbie
 
Registered: Apr 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
I meant on your other post from page1 just edit and change thanks and sorry again.
 
Old 01-31-2013, 06:12 PM   #19
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,881

Rep: Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660
I "polished" the code to make it more concise.
Code:
awk 'BEGIN {while (getline < "'"$InFile1"'") a[++j]=$0};
  {if ($0~/hosts/) $0=$1 $2 a[++k] $8}1' $InFile2 > $OutFile
Daniel B. Martin
 
1 members found this post helpful.
  


Reply



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
[SOLVED] delete a matched line from the file+shell script novicunix Programming 13 02-01-2013 08:37 AM
[SOLVED] Replace pattern in specific lines and column with AWK cgcamal Programming 10 04-26-2010 01:11 AM
Text file manipulation: selecting specific lines/columns using awk and print CHARL0TTE Linux - Newbie 2 02-27-2010 02:40 AM
Comparing two files to get matched contents in another file using shell script pooppp Linux - Networking 3 08-05-2008 12:11 AM
How can I use a shell script to add and replace lines in a file? abefroman Programming 10 12-27-2005 05:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:47 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
Open Source Consulting | Domain Registration