LinuxQuestions.org
Register a domain and help support LQ
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, 04: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, 04:13 PM   #17
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 1,153

Rep: Reputation: 303Reputation: 303Reputation: 303Reputation: 303
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, 04: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, 07:12 PM   #19
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 1,153

Rep: Reputation: 303Reputation: 303Reputation: 303Reputation: 303
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


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


All times are GMT -5. The time now is 09:59 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration