Sponsored Content
Top Forums Shell Programming and Scripting Get the 1st 99 characters and add new line feed at the end of the line Post 302402724 by udelalv on Wednesday 10th of March 2010 12:55:12 PM
Old 03-10-2010
Get the 1st 99 characters and add new line feed at the end of the line

I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed).

Code:
AU  *     A01        EXPENSE     6990370000       CWF SUBC TRAVEL & MISC 
MY  *     A02        RESALE      6990788000     Y PERMANENT PLACEMENT FEES-CWS
CZ  *     A04        RESALE      6990788000     Y PERMANENT PLACEMENT FEES-BUS SVCS 
GH  *     A06        EXPENSE     6990375009       TAXES EXPENSES-FROM WWER
CZ  *     A04        RESALE      6990788000     Y PERMANENT PLACEMENT FEES-BUS SVCS MAINTENANCE PAYMENT

I'm using this line of code to achieve this.
Code:
awk '{printf "%-99s\n",$0}' $stagedir/$1_SAVE > $workdir/$1_SAVE

However, we are having problems when the length of a record within the file exceeds 100 characters. The receiving program that processes my output file is unable to parse it correctly.

I was asked to truncate the records first, get the first 99-characters of each line, and then add the line feed character at the end of the line.

How do I do this? Please help me. Thank you.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Add line numbers to end of each line

Hi i would like to add line numbers to end of each line in a file. I am able to do it in the front of each line using sed, but not able to add at the end of the file. Can anyone suggest The following code adds line number to start of each line sed = filename | sed 'N;s/\n/\t/' how can i... (5 Replies)
Discussion started by: rudoraj
5 Replies

2. Shell Programming and Scripting

replace last form feed with line feed

Hi I have a file with lots of line feeds and form feeds (page break). Need to replace last occurrence of form feed (created by - echo "\f" ) in the file with line feed. Please advise how can i achieve this. TIA Prvn (5 Replies)
Discussion started by: prvnrk
5 Replies

3. Shell Programming and Scripting

SED remove line feed and add to certain area

Hi All, I have a xml file and requirement is to remove the line feed and add line feed after some element. <?xml version="1.0" ?> <AUDITRECORDS> <CARF> <HED> <VN1>20090616010622</VN1> <VN2>0</VN2> <VN3>1090</VN3> <VN4>CONFIG_DATA</VN4> ... (8 Replies)
Discussion started by: sreejitnair123
8 Replies

4. UNIX for Dummies Questions & Answers

Inserting control characters at the end of each line

How to add control characters at the end of each line in a file? Can anyone help me with this? Thanks, Shobana (2 Replies)
Discussion started by: Shobana_s
2 Replies

5. UNIX for Dummies Questions & Answers

Append characters to end of line

Coding in unix shell script. Hi All, Please help Thanks (6 Replies)
Discussion started by: sam12345
6 Replies

6. Shell Programming and Scripting

adding characters end of line where line begins with..

Hi all, using VI, can anyone tell me how to add some characters onto the end of a line where the line begins with certain charactars eg a,b,c,......., r,s,t,........, a,b,c,......., all lines in the above example starting with a,b,c, I want to add an x at the end of the line so the... (6 Replies)
Discussion started by: satnamx
6 Replies

7. UNIX for Dummies Questions & Answers

How to specify beginning-of-line/end-of-line characters inside a regex range

How can I specify special meaning characters like ^ or $ inside a regex range. e.g Suppose I want to search for a string that either starts with '|' character or begins with start-of-line character. I tried the following but it does not work: sed 's/\(\)/<do something here>/g' file1 ... (3 Replies)
Discussion started by: jawsnnn
3 Replies

8. Shell Programming and Scripting

Want to remove a line feed depending on number of tabs in a line

Hi! I have been struggling with a large file that has stray end of line characters. I am working on a Mac (Lion). I mention this only because I have been mucking around with fixing my problem using sed, and I have learned far more than I wanted to know about Unix and Mac eol characters. I... (1 Reply)
Discussion started by: user999991
1 Replies

9. Shell Programming and Scripting

Replacing end of line characters

Hello, I'm looking for some help in renaming data-timestamps stored within different calendar directories/files. The calendar directory has hundreds of ICS files: ~/Library/Calendars/F494C908.calendar/Events/92B65E439AAC.ics ~/Library/Calendars/F494C908.calendar/Events/DE7867E61969.ics... (8 Replies)
Discussion started by: Schubi
8 Replies

10. UNIX for Beginners Questions & Answers

awk Command to add Carriage Return and Line Feed

Hello, Can someone please share a Simple AWK command to append Carriage Return & Line Feed to the end of the file, If the Carriage Return & Line Feed does not exist ! Thanks (16 Replies)
Discussion started by: rosebud123
16 Replies
stl_key(4)						     Kernel Interfaces Manual							stl_key(4)

NAME
stl_key - setld kit manufacturing key files DESCRIPTION
Each software product that is distributed as subsets for the setld(8) command has an associated key file. The key file's name consists of the product's unique 3-letter name and a 3-digit version number with the string .k for a suffix. The key file is used by the software kit- ting program kits(1) in producing software distribution packages. A key file has a global data section and a subset descriptor section. The sections are separated by a line containing only two percent signs (%%). The global section specifies the product-level attributes of the product. In this section, lines that begin with number signs (#) are com- ments and are ignored by the kits utility. Attributes are specified as name/value pairs separated by equals signs (=). There must be no white space surrounding the equals sign. There are four mandatory attributes and two optional attributes. Attributes must have non-null values. The attributes are: NAME Mandatory. Specifies the name of the product. The value for NAME is a text string of up to 40 characters. If the string con- tains blank spaces, it must be enclosed in apostrophes (''). CODE Mandatory. Specifies the 3-character product code for the product, for example, OAT. VERS Mandatory. Specifies the 3-digit version code for the product, for example, 100. MI Mandatory. Specifies the pathname of the master inventory file for the product. ROOT Optional. A single-digit integer that is set to 1 if the product is the base operating system. In all other cases, this flag must be a zero (0). If missing, this attribute defaults to zero. COMPRESS Optional. A single-digit integer that is set to 1 to create compressed subset files using the compress(1) utility, thereby sav- ing space on the distribution media. To suppress compression, this attribute is a zero (0). If missing, this attribute defaults to zero. The subset descriptor section contains one subset descriptor line for each subset in the product. Comments are not permitted in this sec- tion. A subset descriptor contains subset-specific attributes in four fields separated by TAB characters. These fields are: Subset name A character string up to 15 characters in length, composed of the 3-letter product code (for example, OAT), a mnemonic iden- tifying the subset (for example, DCB), and the 3-digit version code (for example, 100). All letters in the subset name must be uppercase. Reserved This field must be a single period. Flags A 16-bit unsigned integer Bit 0 is the ``sticky bit,'' indicating when set that the subset cannot be removed. Bit 1 indicates when set that the subset is optional. Bits 2 to 7 are reserved. Bits 8 to 15 are undefined. Description A short description of the subset, delimited by single quotation marks (''); for example, 'Document Building Tools' The subset descriptors must be listed in the order in which the subsets are to be installed by setld. RESTRICTIONS
Comments in the subset descriptor section will cause serious problems when encountered by the kits program. TAB formatting in the subset descriptors is tightly enforced by the kits program. EXAMPLES
The following example illustrates the key file for a hypothetical product kit: # Key file for the Orpheus Document Building Tools kit # # Product-level attributes. # NAME='Orpheus Authoring Tools' CODE=OAT VERS=100 MI=OAT00.mi ROOT=0 COMPRESS=1 # # Subset def- initions follow. # %% OATDCB100 . 0 'Document Building Tools' OATDCBDOC100 . 2 'Document Tools Documenta- tion' RELATED INFORMATION
Commands: kits(1), setld(8) Files: stl_comp(4), stl_ctrl(4), stl_image(4), stl_mi(4) Documents: Guide to Preparing Product Kits delim off stl_key(4)
All times are GMT -4. The time now is 01:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy