08-02-2010
changing a variable length text to a fixed length
Hi,
Can anyone help with a effective solution ?
I need to change a variable length text field (between 1 - 18 characters) to a fixed length text of 18 characters with the unused portion, at the end, filled with spaces.
The text field is actually field 10 of a .csv file however I could cut out the field if it makes it easier.
Thanks
Dave
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Is there a command that sets a variable length?
I have a input of a variable length field but my output for that field needs to be set to 32 char.
Is there such a command?
I am on a sun box running ksh
Thanks (2 Replies)
Discussion started by: r1500
2 Replies
2. Shell Programming and Scripting
If someone out there could help me out with this problem. I would really appreciate it.
I am trying to convert xml into text file(fixed length) using Unix Borne shell scripts.
My xml file:
<root>
<header_rec recordtype="00">
<record_id>00</record_id>
... (0 Replies)
Discussion started by: ram2s2001
0 Replies
3. Shell Programming and Scripting
Hi, I have two files.
File1:
File1 contains two fixed width columns ID of 15 characters length and Name is of 100 characters length.
ID Name
1-43<<11 spaces>>Swapna<<94 spaces>>
1-234<<10 spaces>>Mani<<96 spaces>>
1-3456<<9 spaces>>Kapil<<95 spaces>>
File2:
... (4 Replies)
Discussion started by: manneni prakash
4 Replies
4. Shell Programming and Scripting
Hi, I have two input files.
File1:
ID Name Place
1-234~name1~Newyork
1-34~name2~Boston
1-2345~name3~Hungary
File1 is a variable length file where each column is seperated by delimitter "~".
File2:
ID Country
1-34<<11 SPACES>>USA<<7 spaces>>
1-234<<10 SPACES>>UK<<8... (5 Replies)
Discussion started by: manneni prakash
5 Replies
5. UNIX for Dummies Questions & Answers
I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies
6. UNIX for Dummies Questions & Answers
Hi, all.
I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file:
10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783
19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657
And this is the expected... (2 Replies)
Discussion started by: Everton_Silveir
2 Replies
7. Shell Programming and Scripting
Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types:
(H)eader Records
(D)etail Records
(T)railer Records
The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies
8. Shell Programming and Scripting
Hi,
I have a fixed length text file that needs to be cut into individual files in aix and facing padding issues. If I have multiple blank spaces in the file it is just making it one while cutting the files..
Eg:-
$ - blank space
filename:file.txt
... (2 Replies)
Discussion started by: techmoris
2 Replies
9. Shell Programming and Scripting
Hi,
I have a text file with sample records as
CASE ID: 20170218881083
Original presentment record for ARN not found
for Re-presentment
I want to extract the 23 digit number from this file. I thought of using grep but initially couldn't extract the required number. However, after... (16 Replies)
Discussion started by: dsid
16 Replies
10. Shell Programming and Scripting
Hi Team,
I have an issue to split the file which is having special chracter(German Char) using awk command.
I have a different length records in a file. I am separating the files based on the length using awk command.
The command is working fine if the record is not having any... (7 Replies)
Discussion started by: Anthuvan
7 Replies
fmlcut(1F) FMLI Commands fmlcut(1F)
NAME
fmlcut - cut out selected fields of each line of a file
SYNOPSIS
fmlcut -clist [filename...]
fmlcut -flist [-dchar] [-s] [filename...]
DESCRIPTION
The fmlcut function cuts out columns from a table or fields from each line in filename; in database parlance, it implements the projection
of a relation. fmlcut can be used as a filter; if filename is not specified or is -, the standard input is read. list specifies the fields
to be selected. Fields can be fixed length (character positions) or variable length (separated by a field delimiter character), depending
on whether -c or -f is specified.
Note: Either the -c or the -f option must be specified.
OPTIONS
list A comma-separated list of integer field numbers (in increasing order), with optional - to indicate ranges. For example: 1,4,7;
1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field).
-clist If -c is specified, list specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
Note: No space intervenes between -c and list.
-flist If -f is specified, list is a list of fields assumed to be separated in the file by the default delimiter character, TAB, or by
char if the -d option is specified. For example, -f1,7 copies the first and seventh field only. Lines with no delimiter characters
are passed through intact (useful for table subheadings), unless -s is specified. Note: No space intervenes between -f and list.
The following options can be used if you have specified -f.
-dchar If -d is specified, char is the field delimiter. Space or other characters with special meaning to FMLI must be quoted.
Note: No space intervenes between -d and char . The default field delimiter is TAB.
-s Suppresses lines with no delimiter characters. If -s is not specified, lines with no delimiters will be passed through
untouched.
EXAMPLES
Example 1: Getting login IDs and names
The following example gets the login IDs and names.
example% fmlcut -d: -f1,5 /etc/passwd
Example 2: Getting the current login name
The next example gets the current login name.
example% `who am i | fmlcut -f1 -d" "`
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
fmlgrep(1F), attributes(5)
DIAGNOSTICS
fmlcut returns the following exit values:
0 when the selected field is successfully cut out
2 on syntax errors
The following error messages may be displayed on the FMLI message line:
ERROR: line too long
A line has more than 1023 characters or fields, or there is no new-line character.
ERROR: bad list for c/f option
Missing -c or -f option or incorrectly specified list. No error occurs if a line has fewer fields than the list calls for.
ERROR: no fields
The list is empty.
ERROR: no delimiter
Missing char on -d option.
NOTES
fmlcut cannot correctly process lines longer than 1023 characters, or lines with no newline character.
SunOS 5.10 5 Jul 1990 fmlcut(1F)