help with grep command or other useful command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with grep command or other useful command
# 8  
Old 01-17-2008
Bug Revised Coding

Hi ennstate(Nagarajan G)

Thanks a lot for your revise. I have revised my(your's) coding without END statment and it's work...!! Great..!

But, I don't know why the coding skipped the first line from the calculations..!!
May be, because, it does have only one digit before the decimal point..?
I don't know?

Do you have any Idea?

The Output file after removing the END statement, but, without the calculation of the first line...!!, look like this:
Quote:
960109 914 4.54 25 9.21 40-50.34 14.83 2.81 12 335116.5 0.26 6.8 81.7 D1

940129 559 37.02 24.4822 39.8632 0.86 1.99 17 151 9.0 0.07 0.2 0.4 B1

940130 1047 38.93 24.8982 40.7385 9.52 2.89 20 321 93.9 0.17 1.6 28.7 D1

940131 843 37.78 24.8923 40.768 5.19 2.88 17 322 96.4 0.21 15.9 49.9 D1
So, from first looking for the first line, the script just remove the sign "-" from the Latitude number, without any calculation. And, he didn't remove the sign "-" from the Longitude number, and without any calculation..!!

Any Idea? Why?

However, I'll try again for new data file...!!

I appreciate your help ennstate very much.

Amm
# 9  
Old 01-17-2008
I assumed that those fields are like NUMBER-NUMBER.NUMBER,but i think the first line of the input file had an
25- 9.21 "space" between them , so it was not included in that calculation.

If you expect that the input may contain space in those fields then,we may hav to change the logic

Thanks
Nagarajan G
# 10  
Old 01-17-2008
Hi again

I have discovered the problem some how exactly.

As I mentioned Above, the representation of the digit number in Minutes is the key word for solving this problem. For example, the digit number for the first line is 9.21 NOT 09.21, and the same for the last line, is 8.88 NOT 08.88.
Thats why the coding dosen't want to go throw the calculation for those lines.

Any Idea how to solve this small problem?

Otherwise, any Idea on how to search for it inside the file(Inputfile in this case), and fix it manually by adding ZERO "0"..?

Last output file:
Quote:
960109 914 4.54 25 9.21 40-50.34 14.83 2.81 12 335116.5 0.26 6.8 81.7 D1
940129 559 37.02 24.4822 39.8632 0.86 1.99 17 151 9.0 0.07 0.2 0.4 B1
940130 1047 38.93 24.8982 40.7385 9.52 2.89 20 321 93.9 0.17 1.6 28.7 D1
940131 843 37.78 24.8923 40.768 5.19 2.88 17 322 96.4 0.21 15.9 49.9 D1
951106 732 56.83 24.7907 40.437 5.08 2.66 15 307 61.2 0.18 5.3 15.6 D1
951107 6 3 23.22 24.5112 39-56.35 5.68 1.85 8 222 7.6 0.11 1.5 1.4
951107 912 4.16 24.8515 40.6905 10.00 2.66 9 328 87.4 0.02 0.3 4.2 C1
951108 554 20.09 25 8.88 41-15.85 10.00 2.94 7 339153.6 0.14 5.2211.8 D1
Another problem, it seems that the calculation won't go for all the digit numbers. Mean that, he do skip some arbitrary numbers like this one, 24.5112 39-56.35 , he calculate the first one but, he didn't for the second...?? strange...!!

Any Idea and help are very much appreciate it..

Thanks
Amm
# 11  
Old 01-17-2008
Hi ennstate

Thanks again for your nice comments.

I have checked the input file, and it does include space on it.

So, I think we need to change the logic as you mentioned before.

Plus, I need the output file, to be Tabbed spaced between each columns inside the file.
To make it easy for other applications. Is it possible..!!

Any ways thank you again.

Amm
# 12  
Old 01-17-2008
Firstly before we proceed to fix this,we need to agree on few points.

1) The total number of fields that the input field is going to contain.
2)How are those fields are separated.
3)The position of the fields of interest
4)Possible patterns that those fields can have

Only then we can arrive at a good solution.

The script has missed those two lines
960109 914 4.54 25 9.21 40-50.34 14.83 2.81 12 335116.5 0.26 6.8 81.7 D1 -No hyphen
951107 6 3 23.22 24.5112 39-56.35 5.68 1.85 8 222 7.6 0.11 1.5 1.4 - they are not 4 th & 5 th fields here
951108 554 20.09 25 8.88 41-15.85 10.00 2.94 7 339153.6 0.14 5.2211.8 D1 - No Hyphen

Thanks
Nagarajan G
# 13  
Old 01-18-2008
Bug The different between QUOTE and PHP

Hi Ennstate

Thank you for your reply again.

OK. May I can answer your questions by posting all the input and output file below. But, I have just discovered that and noticed that, there is big different between posting the file as QUOTE and PHP in this html forms.
The QUOTE forms gave arbitrary spacing for the file, with no specific format. Not like the PHP forms, gave the exact format of the file inside my machine, with spacing between each column.

This is the Input file using QUOTE forms:
Quote:
960109 914 4.54 25- 9.21 40-50.34 14.83 2.81 12 335116.5 0.26 6.8 81.7 D1
940129 559 37.02 24-28.93 39-51.79 0.86 1.99 17 151 9.0 0.07 0.2 0.4 B1
940130 1047 38.93 24-53.89 40-44.31 9.52 2.89 20 321 93.9 0.17 1.6 28.7 D1
940131 843 37.78 24-53.54 40-46.08 5.19 2.88 17 322 96.4 0.21 15.9 49.9 D1
951106 732 56.83 24-47.44 40-26.22 5.08 2.66 15 307 61.2 0.18 5.3 15.6 D1
951107 6 3 23.22 24-30.67 39-56.35 5.68 1.85 8 222 7.6 0.11 1.5 1.4 C1
951107 912 4.16 24-51.09 40-41.43 10.00 2.66 9 328 87.4 0.02 0.3 4.2 C1
951108 554 20.09 25- 8.88 41-15.85 10.00 2.94 7 339153.6 0.14 5.2211.8 D1
The same Input file using PHP, which gave the exact format with spacing, as it's look in my machine:
PHP Code:
960109  914  4.54 259.21  40-50.34  14.83   2.81 12 335116.5 0.26  6.8 81.7 D1
940129  559 37.02 24
-28.93  39-51.79   0.86   1.99 17 151  9.0 0.07  0.2  0.4 B1
940130 1047 38.93 24
-53.89  40-44.31   9.52   2.89 20 321 93.9 0.17  1.6 28.7 D1
940131  843 37.78 24
-53.54  40-46.08   5.19   2.88 17 322 96.4 0.21 15.9 49.9 D1
951106  732 56.83 24
-47.44  40-26.22   5.08   2.66 15 307 61.2 0.18  5.3 15.6 D1
951107  6 3 23.22 24
-30.67  39-56.35   5.68   1.85  8 222  7.6 0.11  1.5  1.4 C1
951107  912  4.16 24
-51.09  40-41.43  10.00   2.66  9 328 87.4 0.02  0.3  4.2 C1
951108  554 20.09 25
8.88  41-15.85  10.00   2.94  7 339153.6 0.14  5.2211.8 D1 
And this the output file format using PHP, and you can see, with some how unorganised format after running the AWK code script:
PHP Code:
960109 914 4.54 25 9.21 40-50.34 14.83 2.81 12 335116.5 0.26 6.8 81.7 D1
940129 559 37.02 24.4822 39.8632 0.86 1.99 17 151 9.0 0.07 0.2 0.4 B1
940130 1047 38.93 24.8982 40.7385 9.52 2.89 20 321 93.9 0.17 1.6 28.7 D1
940131 843 37.78 24.8923 40.768 5.19 2.88 17 322 96.4 0.21 15.9 49.9 D1
951106 732 56.83 24.7907 40.437 5.08 2.66 15 307 61.2 0.18 5.3 15.6 D1
951107 6 3 23.22 24.5112 39
-56.35 5.68 1.85 8 222 7.6 0.11 1.5 1.4
951107 912 4.16 24.8515 40.6905 10.00 2.66 9 328 87.4 0.02 0.3 4.2 C1
951108 554 20.09 25 8.88 41
-15.85 10.00 2.94 7 339153.6 0.14 5.2211.8 D1 
The interesting field for me, as I explained before is, 1st filed, 4th ~14th.

So, that's all, and I hope this can answer your questions.

looking forward for your help

Thanks
Amm
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep command giving different result for different users for same command

Hello, I am running below command as root user #nodetool cfstats tests | grep "Memtable switch count" Memtable switch count: 12 Where as when I try to run same command as another user it gives different result. #su -l zabbix -s /bin/bash -c "nodetool cfstats tests | grep "Memtable switch... (10 Replies)
Discussion started by: Pushpraj
10 Replies

2. Shell Programming and Scripting

help with grep command

i have the following lines T2345 T3435 - bugfixed and running T5654 fixed and committed T34541:- fixed and committed i need to extract only the T part (eg:T2345) ,ie i dont want any special characters after it. i have been trying with grep and egrep but with no luck. pls help (11 Replies)
Discussion started by: born
11 Replies

3. Shell Programming and Scripting

help with grep command

i have a file which lists the following T2323 T3445 T67666,T6534,T4546 T7878 i need to extract the numeric part only(ie,without T). i tried this script awk '{print substr($0,2,length($0))}' pmt2.txtOutput 2323 3445 67666,T6534,T4546as u can see the numbers coming after "," remains the... (2 Replies)
Discussion started by: born
2 Replies

4. Shell Programming and Scripting

Help with using grep command with copy command

Hi, im taking an entry Unix class, and as part of my lab assignment I have to copy all files in the /home/david/lab3 directory that have the file extension .save to your lab3/temp directory. I'm having trouble getting the grep to do anything worth while I've been trying to do: cp... (6 Replies)
Discussion started by: Critical jeff
6 Replies

5. UNIX for Dummies Questions & Answers

grep command - help

I need to find the word "who" in a file but only that word. For instance I don't want it to find the word "whoever." Any suggestions? (2 Replies)
Discussion started by: brooksie91
2 Replies

6. Shell Programming and Scripting

Grep Command

Hi, I Want to grep the 500th character of a line in a file. please help on this. Thanks in advance (7 Replies)
Discussion started by: raghulshekar
7 Replies

7. Shell Programming and Scripting

can anyone help with shell script command about searching word with grep command?

i want to search in the current directory all the files that contain one word for example "hello" i want to achieve it with the grep command but not with the grep * (2 Replies)
Discussion started by: aintour
2 Replies

8. Shell Programming and Scripting

Help me on Grep Command

Hi, Can anybody explain me about the below mentioned code. grep "^" $FILENAME | cut -c 1-8,84- | awk '{ if (!($2+$3)) printf $1 "," }' >$TEMP_FILENAME Thanks in advance. (3 Replies)
Discussion started by: Kattoor
3 Replies

9. UNIX for Advanced & Expert Users

how to exclude the GREP command from GREP

I am doing "ps -f" to see my process. but I get lines that one of it represents the ps command itself. I want to grep it out using -v flag, but than I get another process that belongs to the GREP itself : I would like to exclude # ps -f UID PID PPID C STIME TTY TIME CMD... (2 Replies)
Discussion started by: yamsin789
2 Replies

10. Shell Programming and Scripting

grep command

Hi, how to search all occurance of keyword in current directory files and sub folder's files also using grep command. thanks (2 Replies)
Discussion started by: avadhani
2 Replies
Login or Register to Ask a Question