Sponsored Content
Top Forums Shell Programming and Scripting Can i read a file character by character Post 302195829 by chella on Friday 16th of May 2008 03:14:12 AM
Old 05-16-2008
Quote:
read -n nchars
Read returns after reading nchars characters rather than
waiting for a complete line of input.
So -n1 means reading character by character.

Regards,
Chella
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

need to read 3° character from a text file

Hi, I need a script to read the n° character from a text file. eg: if the text file contains the line "123456" ,I nedd a command to display the number 4, as an example. I tried with awk and printf but it seems only works with words separated with spaces, but in this case I have only one word... (15 Replies)
Discussion started by: piltrafa
15 Replies

2. Shell Programming and Scripting

Read First Character of Each Line in File

I need a better way to read the first character of each line in a file and check if it equals the special character ¤. This character tells me where there is a break in the reports. The file has over 500,000 lines. Currently, this is my code - if ] I am using Korn Shell as a scripting... (7 Replies)
Discussion started by: azelinsk
7 Replies

3. UNIX for Dummies Questions & Answers

read a variable character by character, substitute characters with something else

im having trouble doing this: i have a variable with 2 characters repeating e.g. aababbbaaaababaabbaabbba is there a way i can search the variable for a's and b's and then change a's to b's and b's to a's? im guessing its like getting the 1's compliment of the string im doing this in... (2 Replies)
Discussion started by: vipervenom25
2 Replies

4. AIX

check for a particular character inside a file and substitute with a given character?

i am a newbie to shell script,so i want a kshell script in which i need to check for a particular character inside a file through conditional looping(like if ,case,while)and if that character exists ,then substitute a given character to that character. consider a file test.txt,inside the file... (1 Reply)
Discussion started by: karthikprasathk
1 Replies

5. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies

6. Shell Programming and Scripting

Can I read a file character by character?

Hello all respected people, Can i read a file character by character without using sed,awk and perl commands. Thanks in advance. (4 Replies)
Discussion started by: murtaza
4 Replies

7. Shell Programming and Scripting

Deleting all characters from 350th character to 450th character from the log file

Hi All, I have a big log file i want to delete all characters (between 350th to 450th characters) starting at 350th character position to 450th character position. please advice or sample code. (6 Replies)
Discussion started by: rajeshorpu
6 Replies

8. Shell Programming and Scripting

How to read character by character in a file

Hi, How read character by character from a file . and i need replace '.' with null if it comes as a 5 character i am beginner ...please help me (1 Reply)
Discussion started by: kartheek
1 Replies

9. Shell Programming and Scripting

read the text file and print the content character by character..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... without using... (1 Reply)
Discussion started by: samupnl
1 Replies

10. Shell Programming and Scripting

Read character by character in line in which space is also included

Hi friend, I have one file , and i want to read that file character by character. I need this script in ksh. while using read option with -n1 am getting error. while read -n1 c read has bad option And if i am using below script, then if in a line has space like this ( Pallvi mahajan)... (10 Replies)
Discussion started by: pallvi_mahajan
10 Replies
XTextExtents(3X11)						  XLIB FUNCTIONS						XTextExtents(3X11)

NAME
XTextExtents, XTextExtents16, XQueryTextExtents, XQueryTextExtents16 - compute or query text extents SYNTAX
XTextExtents(font_struct, string, nchars, direction_return, font_ascent_return, font_descent_return, overall_return) XFontStruct *font_struct; char *string; int nchars; int *direction_return; int *font_ascent_return, *font_descent_return; XCharStruct *overall_return; XTextExtents16(font_struct, string, nchars, direction_return, font_ascent_return, font_descent_return, overall_return) XFontStruct *font_struct; XChar2b *string; int nchars; int *direction_return; int *font_ascent_return, *font_descent_return; XCharStruct *overall_return; XQueryTextExtents(display, font_ID, string, nchars, direction_return, font_ascent_return, font_descent_return, overall_return) Display *display; XID font_ID; char *string; int nchars; int *direction_return; int *font_ascent_return, *font_descent_return; XCharStruct *overall_return; XQueryTextExtents16(display, font_ID, string, nchars, direction_return, font_ascent_return, font_descent_return, overall_return) Display *display; XID font_ID; XChar2b *string; int nchars; int *direction_return; int *font_ascent_return, *font_descent_return; XCharStruct *overall_return; ARGUMENTS
direction_return Returns the value of the direction hint (FontLeftToRight or FontRightToLeft). display Specifies the connection to the X server. font_ID Specifies either the font ID or the GContext ID that contains the font. font_ascent_return Returns the font ascent. font_descent_return Returns the font descent. font_struct Specifies the XFontStruct structure. nchars Specifies the number of characters in the character string. string Specifies the character string. overall_return Returns the overall size in the specified XCharStruct structure. DESCRIPTION
The XTextExtents and XTextExtents16 functions perform the size computation locally and, thereby, avoid the round-trip overhead of XQuery- TextExtents and XQueryTextExtents16. Both functions return an XCharStruct structure, whose members are set to the values as follows. The ascent member is set to the maximum of the ascent metrics of all characters in the string. The descent member is set to the maximum of the descent metrics. The width member is set to the sum of the character-width metrics of all characters in the string. For each charac- ter in the string, let W be the sum of the character-width metrics of all characters preceding it in the string. Let L be the left-side- bearing metric of the character plus W. Let R be the right-side-bearing metric of the character plus W. The lbearing member is set to the minimum L of all characters in the string. The rbearing member is set to the maximum R. For fonts defined with linear indexing rather than 2-byte matrix indexing, each XChar2b structure is interpreted as a 16-bit number with byte1 as the most significant byte. If the font has no defined default character, undefined characters in the string are taken to have all zero metrics. The XQueryTextExtents and XQueryTextExtents16 functions return the bounding box of the specified 8-bit and 16-bit character string in the specified font or the font contained in the specified GC. These functions query the X server and, therefore, suffer the round-trip over- head that is avoided by XTextExtents and XTextExtents16. Both functions return a XCharStruct structure, whose members are set to the val- ues as follows. The ascent member is set to the maximum of the ascent metrics of all characters in the string. The descent member is set to the maximum of the descent metrics. The width member is set to the sum of the character-width metrics of all characters in the string. For each charac- ter in the string, let W be the sum of the character-width metrics of all characters preceding it in the string. Let L be the left-side- bearing metric of the character plus W. Let R be the right-side-bearing metric of the character plus W. The lbearing member is set to the minimum L of all characters in the string. The rbearing member is set to the maximum R. For fonts defined with linear indexing rather than 2-byte matrix indexing, each XChar2b structure is interpreted as a 16-bit number with byte1 as the most significant byte. If the font has no defined default character, undefined characters in the string are taken to have all zero metrics. Characters with all zero metrics are ignored. If the font has no defined default_char, the undefined characters in the string are also ignored. XQueryTextExtents and XQueryTextExtents16 can generate BadFont and BadGC errors. DIAGNOSTICS
BadFont A value for a Font or GContext argument does not name a defined Font. BadGC A value for a GContext argument does not name a defined GContext. SEE ALSO
XLoadFont(3X11), XTextWidth(3X11) Xlib - C Language X Interface X Version 11 Release 6.6 XTextExtents(3X11)
All times are GMT -4. The time now is 06:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy