01-25-2015
The whole concept of adding a random number of spaces to the end of a string doesn't make any sense to me.
I can see wanting to pad a field with trailing spaces to create a fields that contains exactly X characters:
printf '%-*.*s\n' $X $X "$field_contents"
I can see wanting to pad a field with leading spaces to create a field that contains exactly X characters:
printf '%*.*s\n' $X $X "$field_contents"
I can see wanting to pad a field with trailing spaces to create a field that is at least X characters (but not truncate the field if it is longer):
printf '%-*s\n' $X "$field_contents"
I can see wanting to pdd a field with leading spaces to create a field that is at least X characters (but not truncate the field if it is longer):
printf '%*s\n' $X "$field_contents"
Why do you want to add a random number of space???
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm trying to make a bash shell script that will allow a user to modify another file based on input they give. Maybe someone can see what I'm doing wrong here. I'm still pretty new at this...
Let's say my temp file contains this:
0 1 HELLO 3 4
And here's the code:
old=(0 1 3 4)
new=(zero... (2 Replies)
Discussion started by: Loriel
2 Replies
2. Shell Programming and Scripting
Hey,
Im trying to format the last command to tell me just the user names, logins, and the time that they were logged in. So far I got the users logins using a loop that counts the amount of times a user logged in but im not sure how to start the time array. The time im trying to use is the last... (2 Replies)
Discussion started by: Trilogie
2 Replies
3. Shell Programming and Scripting
I have string as and I want to print first two words as output. (3 Replies)
Discussion started by: Diggi
3 Replies
4. Shell Programming and Scripting
Im trying to add 5 blank spaces to the end of each line in a file in a sed script. I can figure out who o put the spaces pretty much anywhere else but at the end.
thanks
Karl (7 Replies)
Discussion started by: karlanderson
7 Replies
5. Shell Programming and Scripting
Not sure about the title if someone has a better name for it please lemme know and I will edit the title.
I have several (10+ files) which look something like:
File 1:
12/28/2009 04:0 8
12/28/2009 04:4 4
12/28/2009 05:0 4
.
.
.
File 2:
12/28/2009 04:1 7
12/28/2009 04:2 3... (2 Replies)
Discussion started by: jstrangfeld
2 Replies
6. UNIX for Advanced & Expert Users
Problem: I have a lot of files, the files first line should always have 4 spaces before any text. Occasionally some of the files will miss the leading spaces and it's a problem. This is only in the first line.
So if there are 4 spaces then text, do nothing. If there are not 4 spaces, add 4... (2 Replies)
Discussion started by: Vryali
2 Replies
7. Shell Programming and Scripting
Hi,
I am trying to get lines between the last occurrences of two patterns. I have files that have several occurrences of “Standard” and “Visual”. I will like to get the lines between “Standard” and “Visual” but I only want to retain only the last one e.g.
Standard
Some words
Some words
Some... (4 Replies)
Discussion started by: damanidada
4 Replies
8. Shell Programming and Scripting
Sed replace using same pattern repeating multiple times in a line
I have text like below in a file:
I am trying to replace the above line to following
How can I acheive this?
I am able to do it if the occurrence is for 1 time:
But If I try like below
I am getting like this:
I have to... (4 Replies)
Discussion started by: sol_nov
4 Replies
9. Shell Programming and Scripting
I need to change . into . so that e.g.
A.Jbecomes A. JI have tried sed 's/\./\.\ /g' but that didn't work. (9 Replies)
Discussion started by: locoroco
9 Replies
10. Shell Programming and Scripting
Hi,
My Input File :
"MN.1.2.1.2.14.1.1" :=
"MN_13_TM_4" ( 000000110110100100110001111110110110101110101001100111110100011010110111001 )
"MOS.1.2.1.2.13.6.2" :=
"MOS_13_TM_4" ( 000000110110100100110001111110110110101110101001100111110100011010110111001 )
Like above template,I have... (4 Replies)
Discussion started by: Preeti Chandra
4 Replies
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