PC awk not working properly on OSX


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers PC awk not working properly on OSX
# 1  
Old 07-15-2009
PC awk not working properly on OSX

Hi,

I'm having some trouble with an awk programme that i'm using to scan ascii files.

Unfortunately I'm not an experienced programmer but I think I am experiencing problems for a two reasons:

1) the awk was written by a PC programmer and it works on his machine, but only partly works on my mac in terminal/darwin

2) the ascii output files the awk is reading are very dirty


my ascii columns are as follows:

1: ref, 2: ignore, 3: temp, :4 water content

I am using the awk to pick up a freezing event in coulmn 2, so from + to - figures and to tell me when this coincides with a water content over 208

the awk prints all the above to below zero crossing events with any water content, not just the ones over 208. (there is one that i put in to test)

I have pasted the awk file below, and a sample of an ascii output attached?

my results from the floolwing awk are:

2 -14.4485 209.758
3151 -0.172935 3.4889
11251 -0.270655 4.35053

Any help would be appreciated

Dan

frost.awk:

{
gsub(/E\+000/,"e"); gsub(/E\-000/,"e-") # gets rid of excess zeros, note \ is to define "+" as a charcater not an action

#print $0

if (TOld>=0 && $3<0 && $4>208) print int($1/1),$3/1,$4/1 # checks if temperature drops below zero and prints ref, temp and water

TOld=$3 # resets temperature
}
# 2  
Old 07-15-2009
You may try to run dos2unix on your datafile, remove the last incomplete line and then re-run the awk script. Your input file has MS Windows line endings ...
# 3  
Old 07-15-2009
thanks for look at it.

sorry but maybe i am more of a dummy than you think!Smilie I think dos 2unix converst ascii files from one to the other, right? However I dont know how to run this tool or programme or whatever it is.

regarding the last incomplete line what is wrong with it. This really is all new to me, sorry

D
# 4  
Old 07-15-2009
OK,
first of all try to run the following command:

Code:
dos2unix <your_input_file>

If your filename is copy.txt, the command will be:

Code:
dos2unix copy.txt

Some old versions of the dos2unix require an output filename:

Code:
dos2unix copy.txt copy.txt

# 5  
Old 07-15-2009
ok

this is what happens:

dan-brownes-computer:~ danbrowne$ dos2unix /asc/files/1.1.2copy.txt /asc/results/1.1.2copy3.txt
-bash: dos2unix: command not found

any ideas?

Dan
# 6  
Old 07-15-2009
Yes,
dos2unix is not in your search path (most likely it's not installed).

Try this instead:

Code:
tr -d '\r' < /asc/files/1.1.2copy.txt > /asc/results/1.1.2copy3.txt

# 7  
Old 07-15-2009
great that works, i get the new file: 1.1.2copy3.txt

however, this 'looks' exactly the same as 1.1.2copy2.txt

is that correct?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk print not working properly

Hello friends, There is one requirment where I need to login into database environment and pull all schema names into a text file ... as of now below are the schemas available... $> describe keyspaces; system_schema system_auth system abc system_distributed system_traces Now from... (4 Replies)
Discussion started by: onenessboy
4 Replies

2. Shell Programming and Scripting

Expansion not working properly

I'm using an Ubuntu machine and expansion is not working properly. What would cause this? Do I need to check for any particular bash packages? $ ipcs -m | grep $USER | awk '{printf "%s ",$2}' $ ipcs -m | grep UNF | awk '{printf "%s ",$2}' 294912 1048577 425986 688131 786436 1245189... (14 Replies)
Discussion started by: cokedude
14 Replies

3. Linux

rexec not working properly

Hi, I am trying to enable rexec to automate certain tasks(it has to be rexec, not ssh or any other due to the system environment), so after switching to linux, I followed the certain instructions that were laid out in the web. My operating system is fedora 17, so I first installed the... (1 Reply)
Discussion started by: wringer
1 Replies

4. Shell Programming and Scripting

uuencode is not working properly

Hello Everyone, I'm very new to the shell script. I'm trying to send multiple attachments in unix using uuencode command. Total I have 3 text files which should be send in mail. but I'm getting 6 files and 3 files with subject as file name. And the content is ` end I'm working... (6 Replies)
Discussion started by: narikivar
6 Replies

5. Red Hat

sudo is not working properly

This is the first time for using sudo for me. # visudo ## Allows people in group admin to run all commands %admin ALL=(ALL) ALL # groupadd admin # useradd temp # usermod -a -G admin temp # id temp uid=506(temp) gid=506(temp) groups=506(temp),507(admin) # #sudo... (5 Replies)
Discussion started by: getrue
5 Replies

6. UNIX for Advanced & Expert Users

Sendmail is not working properly

Hi All, Can any one help me to solve the issue. The Issue is, i have started the sendmail service on my RHEL 4 update 6 box, I am able to send the mail from my box to almost all of the Email Id's except few. Exampe, test mail. . Output is :the message is sent. now if I send the... (2 Replies)
Discussion started by: akhtar.bhat
2 Replies

7. Shell Programming and Scripting

\n not working properly

Hi all, I'm trying to generate a series of txt files starting from a plain csv file part of my code: #!/bin/ksh INSTALLDIR=/Users/ME/Installdir CSV=CSV.csv TMP=/tmp/$(basename $0).txt tr -s "\r" "\n" < /$INSTALLDIR/$CSV > $TMP function Makefiles { printf '%24s:%30s\n' "sometext"... (1 Reply)
Discussion started by: Jive Spector
1 Replies

8. HP-UX

FC card not working properly

Hi I've a problem with Hp-ux 11.11 9000/800/rp3440 system. Already the software for driver & its patch are loaded for HBA Fibrechannel card, but still the fibrechannel card is showing the status "Unclaimed" . What will be reason for this? How to get the status "Claimed" ? Pl. help me out.... (4 Replies)
Discussion started by: Mike1234
4 Replies

9. Programming

y is this not working properly?

#include <stdio.h> #include <sys/types.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> struct stat s; main() { char c; if (fork()==0) { system("clear"); do { printf("myAI\\>§ "); scanf("%s",c); if(stat(c,&s)>-1) {... (3 Replies)
Discussion started by: C|[anti-trust]
3 Replies

10. UNIX for Dummies Questions & Answers

Keyboard not working properly...

Hello Again, Those that have noticed my earlier posts will know that I have succesfully installed Solaris 8 onto my pc. I haven't been able to get x-server working (i think it doesn't like my video card) though I've been able to log into root (with a bit of help from unix forums :o ) and have... (2 Replies)
Discussion started by: timresh
2 Replies
Login or Register to Ask a Question