Script for tracing row in a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script for tracing row in a file
# 1  
Old 11-13-2008
Script for tracing row in a file

Hi!
Sorry for stupid questions, I'm quite unfamiliar win *nix systems
I have a script which generates the file which looks like that:

12.11.2008 06.01 0 0 0 2 2 0 0 0
12.11.2008 06.02 0 0 0 0 0 0 0 0
12.11.2008 06.03 0 0 0 0 0 0 0 0
12.11.2008 06.04 0 0 0 1 1 0 0 0
12.11.2008 06.05 0 0 0 4 4 0 0 0
...

is it possible to create script, to trace if the row contains only 0 and then prints that row? If yes, could somebody give some clues how to do it?
Thanks in advance.
# 2  
Old 11-13-2008
There are plenty of tools/commands for such stuff like "grep" for example.
If these are such a rows for example...
Quote:
12.11.2008 06.02 0 0 0 0 0 0 0 0
12.11.2008 06.03 0 0 0 0 0 0 0 0
... you could just grep for the part with the zeros like
Code:
grep "0 0 0 0 0 0 0 0" infile

# 3  
Old 11-14-2008
Thanks zaxxon,
This works,
but how to create script or command which traces this log
and if line containing zeroes is found it matches it like that or in some color?

12.11.2008 06.01 0 0 0 2 2 0 0 0
12.11.2008 06.02 0 0 0 0 0 0 0 0
12.11.2008 06.03 0 0 0 0 0 0 0 0
12.11.2008 06.04 0 0 0 1 1 0 0 0
12.11.2008 06.05 0 0 0 4 4 0 0 0

thanks in advance
# 4  
Old 11-14-2008
Depends on what you understand about tracing. If you want to trace it while it is being written, maybe do
Code:
tail -f yourfile| grep "0 0 0 0 0 0 0 0"

So when such an entry is written to the log, you only see these on your terminal window.
I have no idea about colored output. I guess that's not worth the trouble.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search row by row from one file to another file if match is found print few colums of file 2

this is the requirement list.txt table1 table2 table3 testfile.txt name#place#data#select * from table1 name2#place2#data2#select * from table 10 innerjoin table3 name2#place2#data2#select * from table 10 output name place table1 name2 place table3 i tried using awk (7 Replies)
Discussion started by: vamsekumar
7 Replies

2. Shell Programming and Scripting

Read row number from 1 file and print that row of second file

Hi. How can I read row number from one file and print that corresponding record present at that row in another file. eg file1 1 3 5 7 9 file2 11111 22222 33333 44444 55555 66666 77777 88888 99999 (3 Replies)
Discussion started by: Abhiraj Singh
3 Replies

3. Shell Programming and Scripting

Subtracting each row from the first row in a single column file using awk

Hi Friends, I have a single column data like below. 1 2 3 4 5 I need the output like below. 0 1 2 3 4 where each row (including first row) subtracting from first row and the result should print below like the way shown in output file. Thanks Sid (11 Replies)
Discussion started by: ks_reddy
11 Replies

4. UNIX for Dummies Questions & Answers

Shell Script: Traverse Database Table Row by Row

Hello Everyone, My issue is that I want to traverse a database table row by row and do some action on the value retrieved in each row. I have gone through a lot of shell script questions/posts. I could find row by row traversal of a file but not a database table. Please help. Thanks &... (5 Replies)
Discussion started by: ahsan.asghar
5 Replies

5. Shell Programming and Scripting

Get a group of line from different file and put them into one file row by row

hi guys, today i'm stuck in a new problem. the title explain more or less but a particular had been omitted. So i'm going to describe below the situation with an example. I have different html files and each of them have a consecutive lines group inside that i want to extract. example: ... (8 Replies)
Discussion started by: sbobotex
8 Replies

6. UNIX for Dummies Questions & Answers

File access tracing

Hello.. Is there anyway to check if some processes are reading one file? Id use inotify, but my kernel is 2.6.9, so it doesnt work. -k- (2 Replies)
Discussion started by: Kimmo_
2 Replies

7. UNIX for Dummies Questions & Answers

Tracing file installation

Hello, my first post here. I have a script to install a program which runs the user through installation interface offering several options. What I want to do is to trace the possible mistakes during the installation and send them to a logfile. I.e if a user interrupts the installation, I would... (2 Replies)
Discussion started by: tetreb
2 Replies

8. Solaris

Tracing a shell script!!!

Hi all, I would like to know how to trace a shell script.. I meant i used the set -x command and also tried, $ bash -xv <script name> but the problem is am a newbie and did not understand what those + and ++ meant at the beginning of each line...(once the execution of the script starts),... (1 Reply)
Discussion started by: wrapster
1 Replies

9. UNIX for Advanced & Expert Users

Tracing file modifications

Hello all! Is there a way or a utility to trace any kind of file changes in a particular directory on any UNIX machine? The purpose is that in Unix, there are multiple ways of opening and making changes to a file. But internally, there must be something common (a single pipe, etc.) that is... (3 Replies)
Discussion started by: gupta_ca
3 Replies

10. Shell Programming and Scripting

Changing the column for a row in a text file and adding another row

Hi, I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value . For Eg . if the input file has a row : abc xyz lmn 89 lm nk o p I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies
Login or Register to Ask a Question