![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| parse through one text file and output many | sophiadun | UNIX for Dummies Questions & Answers | 14 | 02-20-2008 06:08 AM |
| parse text file | craggm | Shell Programming and Scripting | 9 | 02-27-2007 02:13 AM |
| Parse Text file and send mails | Amruta Pitkar | UNIX for Dummies Questions & Answers | 12 | 08-11-2006 04:56 AM |
| How to parse a text file with \034 as field and \035 as end of message delimiter? | indianya | Shell Programming and Scripting | 1 | 08-26-2005 10:20 PM |
| parse text or complex grep ? | jacost | UNIX for Dummies Questions & Answers | 4 | 04-29-2004 08:58 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
parse text file
i am attempting to parse a simple text file with multiple lines and four fields in each line, formatted as such:
12/10/2006 12:34:06 77 38 this is what i'm having problems with in my bash script: sed '1,6d' $RAWDATA > $NEWFILE #removes first 6 lines from file, which are headers/unneeded mv $RAWDATA $BACKUP #saves untouched data file to backup mv $NEWFILE $RAWDATA #repositions data file (minus the 6 header lines) to the orginal filename sed 144q $RAWDATA > $NEWFILE #we only want the first 144 lines sed = $NEWFILE | sed 'N;s/\n/\=/' > $RAWDATA #number the lines (not sure if this is needed) CURTEMP=`awk '/${LINENUM}=/ {print $3}' $RAWDATA` everything works up until the last line. $LINENUM is set previously to 1 (first line). i'm brand new to scripting and 'awk' so i've probably screwed this all up. when i do the awk cmd from the command line without the variables it works. but when i run the script, this line return CURTEMP as blank. the command line i use is awk '/133=/ {print $3}' data.txt and that works fine.. so not exactly sure where i went wrong, i just know that i went wrong. hopefully ya'll can straighten me out on this. thanks in advance |
|
||||
|
thanks! I tried both, the first option did not work. the second option got me a result, but it spits out 15 lines, instead of just one. what i need the script to do is this
read 1st line, take third field which is temperature read 2nd line, take third field, compare to result from previous line, if higher, mark as MAX and move on to next line, if lower, just move on to next line. read 3rd line, take third field, compare to result from previous line, if higher, mark as MAX and move on to next line, if lower, just move on to next line etc... all the way through line 144 which would be the last line in the file. i have the script set to number the lines as such 1=time date temp humidity 2=time date temp humidity .... 144=time date temp humidity any help is appreciated.. thank you! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|