Register
It is currently Wed Apr 23, 2014 5:36 pm

Combining Results and Pausing Output


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Fri Apr 30, 2010 6:57 pm   

Joined: Fri Apr 30, 2010 6:42 pm
Posts: 4
Greetings,

I have exported my putty sessions on my windows box to a .reg file. For each server entry, I need to pull session name and host name. I am able to get this info but have been unable to combine the results on one line.

The closest I have gotten is:
Code:
egrep '(session|hostname)' sourcefile

The results of session and hostname are on separate lines in STDOUT.

I need to:

a. join each match of session and hostname onto one line
b. either before or after the join, I need to run cut or awk to print only the fields I need
c. once I have done a & b, I want it to echo each match one at a time. perhaps print one line of session/hostname then wait for the "any key" to be pressed before presenting the next result.

Thank you in advanced for your assistance!

Best regards,
Brenden


Top
 Profile  
 PostPosted: Fri Apr 30, 2010 9:17 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 512
Hi,

Providing a sample of your sourcefile would help figure how to handle the job.

anyway, I guess I'd pick sed to do a & b, and feed an array.

the c part could be a for-loop:
Code:
for array_element in "${array[@]}"
do read -sn1 -p "$array_element"
   printf "cub ${#array_element}" el | tput -S
done


Top
 Profile  
 PostPosted: Sat May 01, 2010 12:46 am   

Joined: Fri Apr 30, 2010 6:42 pm
Posts: 4
Thank you for your reply.

The reason for not posting my source is because it wasn't producing results near to what I was looking for. It would print all of the sessions first then all of the hostnames. The grep command I posted was the closest as it would print the session and corresponding hostname, just not on the same line.

I will give this a shot and see how it goes!

Brenden


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP