Newbie help needed for comparing values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Newbie help needed for comparing values
# 1  
Old 02-01-2011
Newbie help needed for comparing values

Being linux administrator my task is to keep the machines up and running .Everyday i get a report of list of machines that are up and running.
it would be nice if i get list of machines that are shutdown in comparison to yesterdays report.
for example.If there are 5 machines in my environment
Namely A,B,C,D and E respectively.
Yest report (Running Machines)
Machine A
Machine B
Machine C
Todays Report (Running Machines) .
Machine D
Machine A

I would like to see The Difference between above two cases.
For example
Machine B,C should be reported to derive at conclusion that Machine B and C are shutdown .
How would i include this logic in script?

---------- Post updated at 11:35 PM ---------- Previous update was at 11:02 PM ----------

I m working on diff till now i m able to generate this.
How would i avoid listing unnecessary characters like ">" ,"0a1" ,"2,3d2".
Also MachineD is not needed how would i avoid this?


Code:
# diff -s list1 list2
0a1
> MachineD
2,3d2
< MachineB
< MachineC

# 2  
Old 02-01-2011
Code:
 grep -v -f today yesterday | awk '{print $0" is shutdown"}'

# 3  
Old 02-01-2011
Quote:
Originally Posted by homeboy
Code:
 grep -v -f today yesterday | awk '{print $0" is shutdown"}'

Working fine for above code but if one of the file has empty line then above code output nothing.
# 4  
Old 02-01-2011
Quote:
Originally Posted by pinga123
Working fine for above code but if one of the file has empty line then above code output nothing.
Do you means there're always say 4 machines and you wanna output the un-boot machine?
# 5  
Old 02-01-2011
In reality there are 200 machines and yes i want to output unboot machines.
# 6  
Old 02-01-2011
Then you can list all your machines' names in "yesterday" and use that code,and machines which are running in "today",i think it'll give you the result.you can read the man page of "grep" to know what "-v" option means.^_^
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script needed for comparing two files

Hi, I need shell script to compare the two files based on certain fields and output should contains the required fields based on result.pls find sample input files and required output file 1 COUNT, BNG_IP,PORT,OVLAN 22 , 10.238.60.129,1/1,2009 144 , 10.238.60.129,1/1,2251 ... (5 Replies)
Discussion started by: surender reddy
5 Replies

2. Shell Programming and Scripting

Linux newbie scripting help needed (timer)

Hi, Newbie to Linux needing some help with scripting, here. I've written a script that allows easily shutting down, rebooting, or exiting to terminal mode via a Dialog menu after logging out of X-server. In my .bash_profile I have startx followed by running my script, shutdownmenu.sh, and it... (1 Reply)
Discussion started by: Pop45398
1 Replies

3. Shell Programming and Scripting

Need help with awk to get values from input (newbie here)

Hello everyone! I have a small text file called processes.txt which contains a few lines in this fashion: ID: 35; Arrival_Time: 0; Total_Exec_Time: 4; ID: 36; Arrival_Time: 1; Total_Exec_Time: 6; I am trying to figure out how I can get the values from between the delimiters ';' and ':' per... (16 Replies)
Discussion started by: mehungry
16 Replies

4. Shell Programming and Scripting

Scripting needed for newbie

Hi, I am newbie in shell scripting I have a file name like simple.txt which comes from Mainframe systems onto windows dir every 15 minutes daily. File name is same. Every 15 minutes it updates. I need to write shell script to check if the file arrived every 15 min or not. If the new file... (4 Replies)
Discussion started by: chinniforu2003
4 Replies

5. Shell Programming and Scripting

comparing values

i have two file and i am comparing both.. in cmp1 ,the content is : the nu of file is : <some integer value> in cmp2 ,the content is : the nu of file is : so want a script which will take value (2) when cmp1 is compared with cmp2.. i mean cmp cmp1 cmp2 the the output will be he nu of... (1 Reply)
Discussion started by: Aditya.Gurgaon
1 Replies

6. Shell Programming and Scripting

Hi Needed help for Unix Newbie

Hi, Can i get some help from any of you guyz on writing Unix script. my requirement is like reading a csv file, finding a specific pattern in the lines and repalce the string with new string and write it to another file. My file is file ABC123.dat Col1,Col2,Col3 102628,AB10 0,21... (2 Replies)
Discussion started by: prashant_jsw
2 Replies

7. Programming

newbie to unix programming in C, needed a few simple prgs on these functions!

Hi all, I am a newbie to unix programming using C.. So i would like to have a few simple C programs to start off with.. I wanted programs on learning , abort,kill and raise,alarm and pause,I would also like to know how to use the vfork() in a prg It would be really great if i can have... (1 Reply)
Discussion started by: wrapster
1 Replies

8. Shell Programming and Scripting

comparing values of same variable

Hello all while writing a small script , i got stuck with this simple thing.Hope you guyz can help. Iam trying to read password echo"enter password" read $pwd now i have to check this echo"enter password to proceed" read $pwd now i have to check both the values of the... (2 Replies)
Discussion started by: coolkid
2 Replies

9. HP-UX

urgent help needed on HP 9000 rp3410 server for a newbie

Hi friends i dont know whether it is the right forum to ask this or not. if its not please excuse me and please give me the link for such a forum. i am novice about HP 9000 rp3410 server and its things but i had to install and configure it. I came to know that it doesnot comes with builtin... (4 Replies)
Discussion started by: bnaravinda
4 Replies

10. UNIX Desktop Questions & Answers

Newbie help needed connecting to Internet

I have an Ultra5 with 2.56 that is connected to a network. We don't use a proxy server on the network but access the internet directly through a gateway. How do I configure the Solaris box to see the internet? Opening the internet explorer and setting HTTP; FTP etc ports to the ip of the... (3 Replies)
Discussion started by: FattyLumpkin
3 Replies
Login or Register to Ask a Question