Sponsored Content
Top Forums Shell Programming and Scripting Quick Question concerning Reading and Writing Post 302572378 by astropi on Wednesday 9th of November 2011 08:48:26 PM
Old 11-09-2011
Quick Question concerning Reading and Writing

First off, this is not homework nor for any class.

I have a file (column) of data such as:

12.56
2.78
0.54
22.7
... etc.

(call the file "num") I want to read in each line, then check to see whether it's greater than or equal to a value, say "1". If it is, save it in one file, if it's not, save it in another file. So in other words, I'll end up with two files, each a column of data. Below is what I tried:

Code:
read a < num
if [ "${a}" -ge 1 ]; then 
    ${a} >> OK.txt
else
    ${a} >> BAD.txt
fi

It appears to work for the very first line, but then stops. I'm sure there's a simple way to get what I want, but I don't know how. Help, would certainly be appreciated! Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Reading and Writing Files ?

Hello, Our group is just starting to get into UNIX here. We are former REXX users on a VM Mainframe. Can someone point me to the documentation to read a file and write a file in a Unix Shell Script or does this have to be done in another language? Thank you in advance... Dave (3 Replies)
Discussion started by: tracydp
3 Replies

2. Programming

Reading and Writing file on LAN

Hi gurus I am not a C programmer but I need to read and write files on a computer on LAN using IP address. Suppose on a computer that has an IP 192.168.0.2 Any help or code example. I did in JAVA using URL, but do not know how to do in ANSI-C. In java: ------- URL url = new... (3 Replies)
Discussion started by: lucky001
3 Replies

3. Shell Programming and Scripting

reading/ writing to sockets

Is it possible to read from or write to sockets with ksh? I use AIX 5.3 (1 Reply)
Discussion started by: rein
1 Replies

4. UNIX and Linux Applications

Reading and Writing from Excel using Unix scripting

Hi All, I want to read and write into Excel files. I want my script to generate the required output directly in the Excel format. Is it possible through unix scripting or shall I have to use some other language for this purpose? Waiting for your suggestion. Thanks in Advance. ... (3 Replies)
Discussion started by: AshishK
3 Replies

5. UNIX for Dummies Questions & Answers

reading ,writing,appending ,manipulating a file.

Hi my prob statement is to create a new file or to append to the 1tst file the followign chages. File 1: txt file. portfolio No a b c d abc 1 Any Any Any charString cds 2 values values values charString efd 3 can can can charString fdg 4 come come come charString... (4 Replies)
Discussion started by: szchmaltz
4 Replies

6. UNIX for Dummies Questions & Answers

Log File Writing and Reading

Hi all, I have the following shell script code which tries to sftp and writes the log into the log file. TestConnection () { echo 'Connection to ' $DESTUSERNAME@$DESTHOSTNAME $SETDEBUG if ]; then rm $SCRIPT ; fi touch $SCRIPT echo "cd" $REMOTEDIR >> $SCRIPT echo "quit" >>... (10 Replies)
Discussion started by: valluvan
10 Replies

7. Programming

I need help with file reading/writing in C

Hello everybody, I'm trying to code a program which makes the following: It sends an ARP request frame and when it gets the reply, extracts the IP address of source and writes it to a .txt file. This is gonna be done with many hosts (with a for() loop), so, the text file would look like... (2 Replies)
Discussion started by: Zykl0n-B
2 Replies

8. UNIX for Dummies Questions & Answers

Reading and writing data to and from multiple files

Hi, I have several text files. One main file contains the detail data, other have some information to extract data from the main file, and some are empty files. Examples are shown below: The main file look like: MainFile.txt >Header1 data1...data1... >Header2 data2...data2... ... ...... (2 Replies)
Discussion started by: Fahmida
2 Replies

9. Shell Programming and Scripting

reading from and writing to serial port

hello all, please any one can provide me the shell script to write data to /dev/ttyS1 and read responce from /dev/ttyS1 and compare the responce to some string .. thnxx ---------- Post updated at 03:35 PM ---------- Previous update was at 11:46 AM ---------- any body help me.. how do i... (1 Reply)
Discussion started by: yashwantkumar
1 Replies

10. Shell Programming and Scripting

Reading and writing in same file

Hi All, Here is my requirement. I am grepping through the log files and cutting some fields from the file to generate a csv file. Now I have to check if 2nd field is having some fixed value then with the help of 4th field I have to look in same log and run another grep command to retrieve the... (11 Replies)
Discussion started by: kmajumder
11 Replies
Reading/Writing(3)						    globus xio							Reading/Writing(3)

NAME
Reading/Writing - globus_xio_register_read() semantics: If the waitforbytes parameter is greater than zero, the read will happen asynchronously and be completed when at least waitforbytes has been read/written. If the waitforbytes parameter is equal to zero, one of the following alternative behaviors occur: If the length of the buffer is > 0 the read happens synchronously. If the user is using one of the blocking xio calls, no internal callback will occur. If the length of the buffer is also 0, the call behaves like an asynchronous notification of data ready to be read. ie, an asynchronous select(). In any case, when an error occurs before the waitforbytes request has been met, the outgoing nbytes is set to the amount of data actually read before the error occurred. If the handle is not connected, the user should pass in a data descriptor. After the read, this data_descriptor will contain the contact string of the sender. The user can either get this contact string with GLOBUS_XIO_UDP_GET_CONTACT or pass the data descriptor directly to globus_xio_register_write() to send a message back to the sender. Also, if the handle is not connected, the waitforbytes should probably be 1 to guarantee that only one packet is received and the sender contact isnt overwritten by multiple packets from different senders. globus_xio_register_write() semantics: When performing a write, exactly one UDP packet is sent of the entire buffer length. The waitforbytes parameter is ignored. If the entire buffer can not be written, a GLOBUS_XIO_UDP_ERROR_SHORT_WRITE error will be returned with nbytes set to the number of bytes actually sent. If the handle is not 'connected', a contact string must be set in the data descriptor to globus_xio_register_write(). This can either be done explicitly with GLOBUS_XIO_UDP_SET_CONTACT or implicitly by passing in a data descriptor received from globus_xio_register_read(). The udp write semantics are always synchronous. No blocking or internal callback will occur when using globus_xio_write(). Author Generated automatically by Doxygen for globus xio from the source code. Version 3.3 Mon Apr 30 2012 Reading/Writing(3)
All times are GMT -4. The time now is 03:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy