Sponsored Content
Top Forums UNIX for Dummies Questions & Answers removing a character and addending to end in each line in a file Post 302162740 by arunkumar_mca on Tuesday 29th of January 2008 11:48:17 PM
Old 01-30-2008
thanks ... I got into my head how it works Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing character from list line (at the end)

Hi, I have file as shown below. abc, def, abc, xyz, I have to remove ',' from end of last line (xyz,). How can I do that with single command? Is it possible or I have to iterate through complete file to remove that? - Malay (2 Replies)
Discussion started by: malaymaru
2 Replies

2. UNIX for Advanced & Expert Users

Deleting end of line $ character in file

Hi, I've got a file where in the middle of the record is a $ end of line character, visible only when I open the file in vi and do :set list. How to I get rid of the character in the middle and keep it at the end. The middle $ character always appears after SW, so that can be used to tag it.... (3 Replies)
Discussion started by: bwrynz1
3 Replies

3. UNIX for Dummies Questions & Answers

How to add new line character at the end of a file

hi all, i have this question: How to add new line character at the end of a file???? i need this because i am loading a file to sybase and i have problems with the last record thanks for your help (5 Replies)
Discussion started by: DebianJ
5 Replies

4. Shell Programming and Scripting

append a character at end of each line of a file

Hi, i want to append a character '|' at end of each line of a file abc.txt. for example if the file abc.txt conatins: a|b|c 1|2|33 w|2|11 i want result file xyz.txt a|b|c| 1|2|33| w|2|11| I know this is simple but sumhow i am not able to reach end of line. its urgent, thanks for... (4 Replies)
Discussion started by: muaz
4 Replies

5. Shell Programming and Scripting

Removing last character from each line of file

How can I remove the last character from each line of a file? This must be done without "funny" characters, as I want to transfer the code to/from Windows. Any ideas? (17 Replies)
Discussion started by: cjhancock
17 Replies

6. Shell Programming and Scripting

add character to the end of each line in file

hi all i have 32 lines in file. the length of each line is 82 , i want that in the end of each line , means in postion 83-84 to put two characters 0d(=\015), 0a(=\012) i want that the 0d will be in postion 83 and the 0a will be in postion 84 in each line of the file how shall i do it ? ... (7 Replies)
Discussion started by: naamas03
7 Replies

7. UNIX for Dummies Questions & Answers

Removing ^@ character at the end own belowof Linux file

Hi, I have a Linux file which has content as sh (0 Replies)
Discussion started by: bhuvanas
0 Replies

8. Shell Programming and Scripting

add character to every end-of line in file

Hi All I have a file which conatins record.the length of every records is 47. problem : in the end of record i don't have a "\015" character. i want to add this "\015" charcter in the end of every record. the file contains something like 700 records. i've tried with sed command - nothing. ... (8 Replies)
Discussion started by: naamas03
8 Replies

9. Shell Programming and Scripting

How to remove new line character at end of file.

I need to remove new line character from end of file. Suppose here are content. a|b|c|d|r a|b|c|d|r a|b|c|d|r <new line> that means file contains 4 lines but data is there in 3 lines. so I want that only 3 lines should be there in file. Please help (20 Replies)
Discussion started by: varun940
20 Replies

10. Shell Programming and Scripting

Removing last character of a specific line from a file

Hello guys, I would need to remove the last character ")" of a specific line. This can be from any line. Your help is appreciated. Below is the line. HOSTNAME=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)) Please help. (6 Replies)
Discussion started by: sang8g
6 Replies
SCANF(3S)																 SCANF(3S)

NAME
scanf, fscanf, sscanf - formatted input conversion SYNOPSIS
#include <stdio.h> scanf(format [ , pointer ] . . . ) char *format; fscanf(stream, format [ , pointer ] . . . ) FILE *stream; char *format; sscanf(s, format [ , pointer ] . . . ) char *s, *format; DESCRIPTION
Scanf reads from the standard input stream stdin. Fscanf reads from the named input stream. Sscanf reads from the character string s. Each function reads characters, interprets them according to a format, and stores the results in its arguments. Each expects as arguments a control string format, described below, and a set of pointer arguments indicating where the converted input should be stored. The control string usually contains conversion specifications, which are used to direct interpretation of input sequences. The control string may contain: 1. Blanks, tabs or newlines, which match optional white space in the input. 2. An ordinary character (not %) which must match the next character of the input stream. 3. Conversion specifications, consisting of the character %, an optional assignment suppressing character *, an optional numerical maximum field width, and a conversion character. A conversion specification directs the conversion of the next input field; the result is placed in the variable pointed to by the corre- sponding argument, unless assignment suppression was indicated by *. An input field is defined as a string of non-space characters; it extends to the next inappropriate character or until the field width, if specified, is exhausted. The conversion character indicates the interpretation of the input field; the corresponding pointer argument must usually be of a restricted type. The following conversion characters are legal: % a single `%' is expected in the input at this point; no assignment is done. d a decimal integer is expected; the corresponding argument should be an integer pointer. o an octal integer is expected; the corresponding argument should be a integer pointer. x a hexadecimal integer is expected; the corresponding argument should be an integer pointer. s a character string is expected; the corresponding argument should be a character pointer pointing to an array of characters large enough to accept the string and a terminating `', which will be added. The input field is terminated by a space character or a new- line. c a character is expected; the corresponding argument should be a character pointer. The normal skip over space characters is suppressed in this case; to read the next non-space character, try `%1s'. If a field width is given, the corresponding argument should refer to a character array, and the indicated number of characters is read. e a floating point number is expected; the next field is converted accordingly and stored through the corresponding argument, which f should be a pointer to a float. The input format for floating point numbers is an optionally signed string of digits possibly contain- ing a decimal point, followed by an optional exponent field consisting of an E or e followed by an optionally signed integer. [ indicates a string not to be delimited by space characters. The left bracket is followed by a set of characters and a right bracket; the characters between the brackets define a set of characters making up the string. If the first character is not circumflex (^), the input field is all characters until the first character not in the set between the brackets; if the first character after the left bracket is ^, the input field is all characters until the first character which is in the remaining set of characters between the brackets. The corresponding argument must point to a character array. The conversion characters d, o and x may be capitalized or preceeded by l to indicate that a pointer to long rather than to int is in the argument list. Similarly, the conversion characters e or f may be capitalized or preceded by l to indicate a pointer to double rather than to float. The conversion characters d, o and x may be preceeded by h to indicate a pointer to short rather than to int. The scanf functions return the number of successfully matched and assigned input items. This can be used to decide how many input items were found. The constant EOF is returned upon end of input; note that this is different from 0, which means that no conversion was done; if conversion was intended, it was frustrated by an inappropriate character in the input. For example, the call int i; float x; char name[50]; scanf( "%d%f%s", &i, &x, name); with the input line 25 54.32E-1 thompson will assign to i the value 25, x the value 5.432, and name will contain `thompson'. Or, int i; float x; char name[50]; scanf("%2d%f%*d%[1234567890]", &i, &x, name); with input 56789 0123 56a72 will assign 56 to i, 789.0 to x, skip `0123', and place the string `56' in name. The next call to getchar will return `a'. SEE ALSO
atof(3), getc(3), printf(3) DIAGNOSTICS
The scanf functions return EOF on end of input, and a short count for missing or illegal data items. BUGS
The success of literal matches and suppressed assignments is not directly determinable. SCANF(3S)
All times are GMT -4. The time now is 12:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy