Help to find length of string avoiding trailing spaces
Hi,
I have a record of length 200 bytes and values filled is only 100 bytes and remaining 100 spaces is occupied by spaces. In script wen i try to find the length of the entire record it should get as 200 not 100. i tried using length and wc -c but it doesnt work can anyone have any idea on this???
Tis was the code i tried:-
I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help.
echo $SH_VAR | command_line Syntax.
The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Hi,
I have a file like this
(ADD_MONTHS((Substr(Trim(BOTH FROM Translate(Maximum(closeDa
------------------------------------------------------------
2007-06-30 00:00:00
I have a requirement where i need just the date.
When i do: tail -1... (2 Replies)
Hi ,
I have a file named "sample" having the data as follows.
"663005487","USD",0,1,"NR"
If i give like
a=`awk -F ',' '{printf length($2)}' sample`
(Trying to find length of second field)I should get the output for the above as 3 (Omitting double quotes) not 5.
How to do this..... (2 Replies)
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)
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)
I have textfile (source.txt) with different length of lines in it. Can anybody help to compose a script under bash which would add suitable number of trailing spaces to the end of each line so that after the processing the each line would have the same (let's say 100 char) length? Output can be... (6 Replies)
Hello People
How to check whether lines in a text file have trailing spaces or not and if a line have trailing spaces then how many trailing spaces line have?
Regards
ARvind kumar (5 Replies)
Hi All
I want to take a Hexadecimal number as input and i want to find lenth of the input and pass it to char s ( char s ). I have a program to convert hexadecial to binary but it is taking limited input but i want to return binary number based on input. How? (1 Reply)
Hi all,
We use strlen() fun provided by library to find the length of a string.
Looking inside of it, it has some different mechanism to find the length of string.
Normally, we scan the string byte by byte until the '\0' character. It takes a logn time to count length.
The Library strlen()... (2 Replies)
Discussion started by: yogeshrl9072
2 Replies
LEARN ABOUT OSX
ar
AR(5) BSD File Formats Manual AR(5)NAME
ar -- archive (library) file format
SYNOPSIS
#include <ar.h>
DESCRIPTION
The archive command ar combines several files into one. Archives are mainly used as libraries of object files intended to be loaded using
the link-editor ld(1).
A file created with ar begins with the ``magic'' string "!<arch>
". The rest of the archive is made up of objects, each of which is com-
posed of a header for a file, a possible file name, and the file contents. The header is portable between machine architectures, and, if the
file contents are printable, the archive is itself printable.
The header is made up of six variable length ASCII fields, followed by a two character trailer. The fields are the object name (16 charac-
ters), the file last modification time (12 characters), the user and group id's (each 6 characters), the file mode (8 characters) and the
file size (10 characters). All numeric fields are in decimal, except for the file mode which is in octal.
The modification time is the file st_mtime field, i.e., CUT seconds since the epoch. The user and group id's are the file st_uid and st_gid
fields. The file mode is the file st_mode field. The file size is the file st_size field. The two-byte trailer is the string "`
".
Only the name field has any provision for overflow. If any file name is more than 16 characters in length or contains an embedded space, the
string "#1/" followed by the ASCII length of the name is written in the name field. The file size (stored in the archive header) is incre-
mented by the length of the name. The name is then written immediately following the archive header.
Any unused characters in any of these fields are written as space characters. If any fields are their particular maximum number of charac-
ters in length, there will be no separation between the fields.
Objects in the archive are always an even number of bytes long; files which are an odd number of bytes long are padded with a newline
(``
'') character, although the size in the header does not reflect this.
SEE ALSO ar(1), stat(2)HISTORY
There have been at least four ar formats. The first was denoted by the leading ``magic'' number 0177555 (stored as type int). These ar-
chives were almost certainly created on a 16-bit machine, and contain headers made up of five fields. The fields are the object name (8
characters), the file last modification time (type long), the user id (type char), the file mode (type char) and the file size (type unsigned
int). Files were padded to an even number of bytes.
The second was denoted by the leading ``magic'' number 0177545 (stored as type int). These archives may have been created on either 16 or
32-bit machines, and contain headers made up of six fields. The fields are the object name (14 characters), the file last modification time
(type long), the user and group id's (each type char), the file mode (type int) and the file size (type long). Files were padded to an even
number of bytes. For more information on converting from this format see arcv(8).
The current archive format (without support for long character names and names with embedded spaces) was introduced in 4.0BSD. The headers
were the same as the current format, with the exception that names longer than 16 characters were truncated, and names with embedded spaces
(and often trailing spaces) were not supported. It has been extended for these reasons, as described above. This format first appeared in
4.4BSD.
COMPATIBILITY
No archive format is currently specified by any standard. AT&T System V UNIX has historically distributed archives in a different format
from all of the above.
BSD June 9, 1993 BSD