Sponsored Content
Full Discussion: Append Spaces to a string
Top Forums UNIX for Dummies Questions & Answers Append Spaces to a string Post 302880934 by Yoda on Tuesday 24th of December 2013 05:23:53 PM
Old 12-24-2013
Akshay,

Please respect if someone in the forum is asking OP a question. Please do refrain from posting answers before the OP get back to us with an answer to the question raised.

I am requesting so just to make sure that the special homework rules are followed.

Thank you
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Append strings with filler spaces

Hi I am looping through the contents of a file as follows cat file |while read inrec do echo $inrec >> $TMP done (obviously this isn't all i am doing as it would be pointless but for the sake of the problem this is the important bit) The file has fields which are separated by... (1 Reply)
Discussion started by: handak9
1 Replies

2. Shell Programming and Scripting

Append Spaces At end of each line Leaving Header and Footer

How to append constant No of spaces suppose 52 at end of each line in a file (xyz) excluding first and last line. Please Help me out for the same. (1 Reply)
Discussion started by: deepam
1 Replies

3. Shell Programming and Scripting

append string with spaces to a line

hi i have a file like (every string contains 16 chars) CTL1330000000000 0000 00 008000 0080000000 i need to form a line and write to a file CTL13300000000000000 00008000 0080000000 total chars should be 64 ... (2 Replies)
Discussion started by: Satyak
2 Replies

4. UNIX for Dummies Questions & Answers

Read a string with leading spaces and find the length of the string

HI In my script, i am reading the input from the user and want to find the length of the string. The input may contain leading spaces. Right now, when leading spaces are there, they are not counted. Kindly help me My script is like below. I am using the ksh. #!/usr/bin/ksh echo... (2 Replies)
Discussion started by: dayamatrix
2 Replies

5. UNIX for Dummies Questions & Answers

how to append spaces(say 10 spaces) at the end of each line based on the length of th

Hi, I have a problem where I need to append few spaces(say 10 spaces) for each line in a file whose length is say(100 chars) and others leave as it is. I tried to find the length of each line and then if the length is say 100 chars then tried to write those lines into another file and use a sed... (17 Replies)
Discussion started by: prathima
17 Replies

6. Shell Programming and Scripting

append end of line with 8 spaces

child_amt=$amount prev_line="$prev_line $child_amt" i am getting the result like this 21234567890001343 000001004OLFXXX029100020091112 0000060 but i want 8 spaces between the eg: 21234567890001343 000001004OLFXXX029100020091112 0000060 how can i do this in .ksh (1 Reply)
Discussion started by: kshuser
1 Replies

7. AIX

How to append spaces to string values?

i/o file: abc,efg,xyz Required o/p file: "abc (Value + blank spaces=16) " ,"efg (Value +blank spaces=15) " ,"xyz (Value+ blank spaces =20) " In short input file value stores in result file with " i/p Value " added with spaces and are of fixed size like 16,15,20 How to do using... (2 Replies)
Discussion started by: AhmedLakadkutta
2 Replies

8. UNIX for Dummies Questions & Answers

Append a string on the next line after a pattern string is found

Right now, my code is: s/Secondary Ins./Secondary Ins.\ 1/g It's adding a 1 as soon as it finds Secondary Ins. Primary Ins.: MEDICARE B DMERC Secondary Ins. 1: CONTINENTAL LIFE INS What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Discussion started by: newbeee
4 Replies

9. Shell Programming and Scripting

append blank spaces at the end of a variable string

Hello, could you please help with this one. I have an input file like this: 123,4567,89000 123456789,9876543,12 and for the output I need strings to be with the fixed length, let's say 15, and if the string is -lt 15 to be populated with blanks at the end until it reach 15, like this: 123 ,4567... (1 Reply)
Discussion started by: apenkov
1 Replies

10. Shell Programming and Scripting

Append spaces the rows to make it into a required fixed length file

I want to make a script to read row by row and find its length. If the length is less than my required length then i hav to append spaces to that paritucular row. Each row contains special characters, spaces, etc. For example my file contains , 12345 abcdef 234 abcde 89012 abcdefgh ... (10 Replies)
Discussion started by: Amrutha24
10 Replies
fopen(3s)																 fopen(3s)

Name
       fopen, freopen, fdopen - open a stream

Syntax
       #include <stdio.h>

       FILE *fopen (filename, type)
       char *filename, *type;

       FILE *freopen (filename, type, stream)
       char *filename, *type;
       FILE *stream;

       FILE *fdopen (fildes, type)
       int fildes;
       char *type;

Description
       The  routine opens the file named by filename and associates a stream with it.  The routine returns a pointer to the FILE structure associ-
       ated with the stream.

       The filename points to a character string that contains the name of the file to be opened.

       The type is a character string having one of the following values:

	  "r"	    Open for reading

	  "w"	    Truncate or create for writing

	  "a"	    Append; open for writing at end of file, or create for writing

	  "A"	    Append with no overwrite; open for writing at end-of-file, or create for writing

	  "r+"	    Open for reading and writing

	  "w+"	    Truncate or create for reading and writing

	  "a+"	    Append; open or create for reading and writing at end-of-file

	  "A+"	    Append with no overwrite, open or create for update at end-of-file

       The letter "b" can also follow r, w, or a. In some C implementations, the "b" is needed to indicate a  binary  file,  however,  it  is  not
       needed in ULTRIX.  If "+" is used, the "b" may occur on either side, as in "rb+" or "w+b".

       The  routine  substitutes  the named file in place of the open stream.  The original stream is closed, regardless of whether the open ulti-
       mately succeeds.  The routine returns a pointer to the FILE structure associated with stream.

       The routine is typically used to attach the preopened streams associated with stdin, stdout and stderr to other files.

       The routine associates a stream with a file descriptor.	File descriptors are obtained from or which open files but do not return  pointers
       to  a  FILE structure stream.  Streams are necessary input for many of the Section 3s library routines.	The type of stream must agree with
       the mode of the open file.

       When a file is opened for update, both input and output may be done on the resulting stream.  However, output may not be directly  followed
       by  input  without  an  intervening  or and input may not be directly followed by output without an intervening or an input operation which
       encounters end-of-file.

       When a file is opened for append with no overwrite (that is when type is "A" or "A+"), it is impossible to overwrite information already in
       the  file.  The routine may be used to reposition the file pointer to any position in the file, but when output is written to the file, the
       current file pointer is disregarded.  All output is written at the end of the file and causes the file pointer to be  repositioned  at  the
       end  of	the  output.   If  two separate processes open the same file for append, each process may write freely to the file without fear of
       destroying output being written by the other.  The output from the two processes will be intermixed in the file in the order in which it is
       written.

Return Values
       The and routines return a NULL pointer on failure.

Environment
   SYSTEM_V
       When  your  program is compiled using the System V environment, append with no overwrite is specified by using the "a" or "a+" type string,
       and the "A" and "A+" type strings are not allowed.

   POSIX
       In the POSIX environment, the "a" and "a+" strings, and the "A" and "A+" strings specify append with no overwrite.

See Also
       creat(2), dup(2), open(2), pipe(2), fclose(3s), fseek(3s).

																	 fopen(3s)
All times are GMT -4. The time now is 02:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy