Sponsored Content
Top Forums UNIX for Dummies Questions & Answers reading ,writing,appending ,manipulating a file. Post 302204886 by szchmaltz on Thursday 12th of June 2008 09:41:37 PM
Old 06-12-2008
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
trh 5 here here here charString


File 2: txt file.
No Imp1 Imp2
1 D v1
1 D v2
1 D v3
2 R v4
2 R v5


create this - txt file.


portfolio No a b Imp1 Imp2(String) c d

abc 1 Any Any D v1,v2,v3 Any charString
cds 2 values values R v4,v5 values charString
efd 3 can can can charString
fdg 4 come come come charString
trh 5 here here here charString

Now in this output there are many some more than 15 columns like i mentioned just (a b ) for ex above...
Please help to get this output by shel script.
Also the No could grow to any extent.
Thanks..
 

10 More Discussions You Might Find Interesting

1. Cybersecurity

Reading and Manipulating captured packets (pflog file)

Hey, I currently have a set of captured sessions thru ethereal, saved in pflog files, basically its a tcpdump, which i need to go thru and sort the applications/protocols in order of the times they were used. I also need to change the headers of the packets, basically the source and destination... (0 Replies)
Discussion started by: PenguinDevil
0 Replies

2. Shell Programming and Scripting

Reading specific contents from a file and appending it to another file

Hi, I need to write a shell script (ksh) to read contents starting at a specific location from one file and append the contents at specific location in another file. Please find below the contents of the source file that I need to read the contents from, File 1 -----# more... (5 Replies)
Discussion started by: dnicky
5 Replies

3. 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

4. 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

5. UNIX for Dummies Questions & Answers

issue on reading the file and appending date

Hi Am having issue on appending time stamp I know the exact file names in the directory like a.dat b.dat c.dat e.dat f.dat I want to read all these file names and append the timestamp to each files like a.dat.20090604,b.dat.20090604 and move to the different directory. ... (3 Replies)
Discussion started by: bobprabhu
3 Replies

6. 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

7. Shell Programming and Scripting

Reading data from DataBase and Writing to a file

Hi All, Please help me in writing data to a file in one row. In database there is a column which contains large data which does not fit in the file in one row. The column contains list of paths. I want to write these paths to a file in one row. Please find the code below writes : ... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

8. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

9. Programming

unexpected values received when writing and reading from file

In the code below i try to write and read from a file, but i get unexpected results, like after writing i cannot open the file, and when reading the file the value entered earlier is not shown bool creat_fragments(int nFragment) { int fd, rand_value; char frag_path, buf; for(int... (8 Replies)
Discussion started by: saman_glorious
8 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
TIFFOpen(3T)															      TIFFOpen(3T)

NAME
TIFFOpen, TIFFFdOpen, TIFFClientOpen - open a TIFF file for reading or writing SYNOPSIS
#include <tiffio.h> TIFF* TIFFOpen(const char* filename, const char* mode) TIFF* TIFFFdOpen(const int fd, const char* filename, const char* mode) typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*); typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t); TIFF* TIFFClientOpen(const char* filename, const char* mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc) DESCRIPTION
TIFFOpen opens a TIFF file whose name is filename and returns a handle to be used in subsequent calls to routines in libtiff. If the open operation fails, then zero is returned. The mode parameter specifies if the file is to be opened for reading (``r''), writing (``w''), or appending (``a'') and, optionally, whether to override certain default aspects of library operation (see below). When a file is opened for appending, existing data will not be touched; instead new data will be written as additional subfiles. If an existing file is opened for writing, all previous data is overwritten. If a file is opened for reading, the first TIFF directory in the file is automatically read (also see TIFFSetDirectory(3T) for reading directories other than the first). If a file is opened for writing or appending, a default directory is automatically created for writing subsequent data. This directory has all the default values specified in TIFF Revision 6.0: BitsPerSample=1, ThreshHolding=bilevel art scan, FillOrder=1 (most significant bit of each data byte is filled first), Orientation=1 (the 0th row represents the visual top of the image, and the 0th column represents the visual left hand side), SamplesPerPixel=1, RowsPerStrip=infinity, ResolutionUnit=2 (inches), and Compression=1 (no compression). To alter these values, or to define values for additional fields, TIFFSetField(3T) must be used. TIFFFdOpen is like TIFFOpen except that it opens a TIFF file given an open file descriptor fd. The file's name and mode must reflect that of the open descriptor. The object associated with the file descriptor must support random access. TIFFClientOpen is like TIFFOpen except that the caller supplies a collection of functions that the library will use to do UNIX-like I/O operations. The readproc and writeproc are called to read and write data at the current file position. seekproc is called to change the current file position a la lseek(2). closeproc is invoked to release any resources associated with an open file. sizeproc is invoked to obtain the size in bytes of a file. mapproc and unmapproc are called to map and unmap a file's contents in memory; c.f. mmap(2) and mun- map(2). The clientdata parameter is an opaque ``handle'' passed to the client-specified routines passed as parameters to TIFFClientOpen. OPTIONS
The open mode parameter can include the following flags in addition to the ``r'', ``w'', and ``a'' flags. Note however that option flags must follow the read-write-append specification. l When creating a new file force information be written with Little-Endian byte order (but see below). By default the library will create new files using the native CPU byte order. b When creating a new file force information be written with Big-Endian byte order (but see below). By default the library will cre- ate new files using the native CPU byte order. L Force image data that is read or written to be treated with bits filled from Least Significant Bit (LSB) to Most Significant Bit (MSB). Note that this is the opposite to the way the library has worked from its inception. B Force image data that is read or written to be treated with bits filled from Most Significant Bit (MSB) to Least Significant Bit (LSB); this is the default. H Force image data that is read or written to be treated with bits filled in the same order as the native CPU. M Enable the use of memory-mapped files for images opened read-only. If the underlying system does not support memory-mapped files or if the specific image being opened cannot be memory-mapped then the library will fallback to using the normal system interface for reading information. By default the library will attempt to use memory-mapped files. m Disable the use of memory-mapped files. C Enable the use of ``strip chopping'' when reading images that are comprised of a single strip or tile of uncompressed data. Strip chopping is a mechanism by which the library will automatically convert the single-strip image to multiple strips, each of which has about 8 Kilobytes of data. This facility can be useful in reducing the amount of memory used to read an image because the library normally reads each strip in its entirety. Strip chopping does however alter the apparent contents of the image because when an image is divided into multiple strips it looks as though the underlying file contains multiple separate strips. Finally, note that default handling of strip chopping is a compile-time configuration parameter. The default behaviour, for backwards compatibility, is to enable strip chopping. c Disable the use of strip chopping when reading images. BYTE ORDER
The TIFF specification (all versions) states that compliant readers must be capable of reading images written in either byte order. None- theless some software that claims to support the reading of TIFF images is incapable of reading images in anything but the native CPU byte order on which the software was written. (Especially notorious are applications written to run on Intel-based machines.) By default the library will create new files with the native byte-order of the CPU on which the application is run. This ensures optimal performance and is portable to any application that conforms to the TIFF specification. To force the library to use a specific byte-order when creating a new file the ``b'' and ``l'' option flags may be included in the call to open a file; for example, ``wb'' or ``wl''. RETURN VALUES
Upon successful completion TIFFOpen, TIFFFdOpen, and TIFFClientOpen return a TIFF pointer. Otherwise, NULL is returned. DIAGNOSTICS
All error messages are directed to the TIFFError(3T) routine. Likewise, warning messages are directed to the TIFFWarning(3T) routine. "%s": Bad mode. The specified mode parameter was not one of ``r'' (read), ``w'' (write), or ``a'' (append). %s: Cannot open. TIFFOpen() was unable to open the specified filename for read/writing. Cannot read TIFF header. An error occurred while attempting to read the header information. Error writing TIFF header. An error occurred while writing the default header information for a new file. Not a TIFF file, bad magic number %d (0x%x). The magic number in the header was not (hex) 0x4d4d or (hex) 0x4949. Not a TIFF file, bad version number %d (0x%x). The version field in the header was not 42 (decimal). Cannot append to file that has opposite byte ordering. A file with a byte ordering opposite to the native byte ordering of the current machine was opened for appending (``a''). This is a limitation of the library. SEE ALSO
libtiff(3T), TIFFClose(3T) January 9, 1996 TIFFOpen(3T)
All times are GMT -4. The time now is 04:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy