Getting few info from file and then displaying in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting few info from file and then displaying in a file
# 1  
Old 07-08-2011
Getting few info from file and then displaying in a file

I have a file(abc.txt) with the following content:
ps -ef|grep Server1|grep Process1 Status1
ps -ef|grep Server2|grep Proces2 Status2
ps -ef|grep Server1|grep Process3 Status1
ps -ef|grep Server1|grep Process4 Status1
ps -ef|grep Server1|grep Process2 Status1

Now I want to write a script to get Server name e.g., Server1/Server2, Process1/Process2/Process... and Status

I want to do some checking based on it and display the result:


How to get it?
# 2  
Old 07-08-2011
Thought this seemed fishy in your other thread.

Why do you have grep in your data file? Why not just store lines like Server1,Process1,Status1 and use it like
Code:
while IFS="," read A B C
do
        ps -ef | grep "$A" | grep "$B" "$C"
done < filename.txt

Better yet, explain your whole problem.
# 3  
Old 07-09-2011
I am generating this input file by running a script and to get the final result I want to accomplish this...
# 4  
Old 07-09-2011
That's also a very odd way to do it. Why not just print the data the way you want it in the first place? Maybe you could explain what you're actually trying to do?
# 5  
Old 07-10-2011
Thanks a lot... ur ideal really helped solve the problem in a smarter way...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inputing info from a CSV file and filling a template file

Hi, I have a .csv file that contains a variety of fields for 60 clients: USERNAME, PASSWORD, and COMMENTS. I have a template file which contains a great deal of data for each client and has the fields USERNAME, PASSWORD, and COMMENTS that has to be filled with the values of USERNAME,... (1 Reply)
Discussion started by: mojoman
1 Replies

2. Shell Programming and Scripting

Add column info from one file to larger second file

Hi, long time reader, first time poster. I've done some searching so please if this is a repeated post excuse the duplicate, but what I have are two files roughly like so: File 1: A W B X C Y D Z File 2: A 1 C 2 D 3 And what I would like to get out is... (4 Replies)
Discussion started by: wallysb01
4 Replies

3. UNIX for Dummies Questions & Answers

Displaying File Information with du and sort

Hi all, I have a network drive that has a directory named "music". In music I have a ton of folders of artists then albums then songs. I wanted to print out all of the songs ordered by artists then albums. I was trying: ********************* du -ka | sort ********************* ... (4 Replies)
Discussion started by: Imhotep1963
4 Replies

4. Shell Programming and Scripting

Displaying Result to a Text File

Hi; I am scripting in Shell and i want to write output (on screen) to a text file? ... | tee gcsw/output.txt doesnot work? :(:( (6 Replies)
Discussion started by: gc_sw
6 Replies

5. UNIX for Dummies Questions & Answers

How can I append a text at end of file after displaying the file

I have a file "sample.txt" with the content as below: Hi This is a Sample Text. I need a single command using cat which serve the following purpose. 1.display the contents of sample.txt 2.append some text to it 3. and then exit But, all should be served by a sinle command.:confused: (1 Reply)
Discussion started by: g.ashok
1 Replies

6. Shell Programming and Scripting

Displaying number of lines from file

Hi, I am using below command to display the number of line, but its returning no of lines along with file name. But i want only no of line in the variable p. Please help me on this? p=`wc -l "text file"` echo "$p" (6 Replies)
Discussion started by: shivanete
6 Replies

7. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies

8. UNIX for Dummies Questions & Answers

displaying the last line of the file

hi... i need to display the last line of the file and capture the line in to a variable in unix envt.(not the perl ones)... please help (8 Replies)
Discussion started by: lmadhuri
8 Replies

9. Programming

Displaying fields in wtmp file?

Anyone have any idea on how to display the fields for each record stored in the wtmp file using C? Am I correct in thinking that the info stored in wtmp is in binary and that utmpx will be of some help? Being a beginner, I can come up with bits and pieces of what I might need in order to do the... (1 Reply)
Discussion started by: eclapton1
1 Replies

10. UNIX for Dummies Questions & Answers

file activity (open/closed) file descriptor info using KORN shell scripting

I am trying to find a way to check the current status of a file. Such as some cron job processes are dependent on the completion of others. if a file is currently being accessed / modified or simply open state I will wait until it is done being processed before attempting the next process on that... (3 Replies)
Discussion started by: Gary Dunn
3 Replies
Login or Register to Ask a Question