Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Trim and pad a field in the middle of unix file Post 302478612 by BSF on Wednesday 8th of December 2010 10:56:26 AM
Old 12-08-2010
That one is nicer, I will keep it!
Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to trim the leading zeroes in a Currency field ?

How do I trim the leading zeroes, and (+,-) in the currency field ? I have a text file. Your bill of +00002780.96 for a/c no. 25287324 is due on 11-06. Your bill of +00422270.48 for a/c no. 28931373 is due on 11-06. I want the O/P file to be like. Your bill of 2780.96 for a/c no. 25287324... (22 Replies)
Discussion started by: Amruta Pitkar
22 Replies

2. Shell Programming and Scripting

How to trim a 419th column in UNIX file.

Hi All, I have a UNIX file, which has Total of 532 column, each delimited with ^~^. One of the column (419) is 202 character long. In real case, it should be 22 character long. cut -d~ -f419 filename ... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

3. Shell Programming and Scripting

Trim leading zeros to make field 6 characters long

Hi all- I've got a file that will have multiple columns. In one column there will be a string that is 10 digits in length, but I need to trim the first four zeros to make it 6 characters? example: 0000001234 0000123456 0000234566 0000000321 output: 001234 123456 234566 000321 (5 Replies)
Discussion started by: Cailet
5 Replies

4. Shell Programming and Scripting

To trim Certain field in a line of a file and replace the new string in that position

To trim 3rd field in for all the lines of a file and replace the modified string in that particular field. For example i have a file called Temp.txt having content Temp.txt ----------------- 100,234,M1234 400,234,K1734 300,345,T3456 ---------------- So the modified file output should... (4 Replies)
Discussion started by: rpadhi
4 Replies

5. Shell Programming and Scripting

Unix File - Adding columns in the middle

Hello, I have a comma separated flat file. It contains some 20 columns. I want to add two new columns at position 2,3. So that file will have 22 columns. I am providing here sample data with file having 4 columns. Appreciate your help in finding solution for this. data in input file:... (11 Replies)
Discussion started by: ravi.videla
11 Replies

6. Shell Programming and Scripting

Pad zeroes first field in a Delimited file

Need help. I tried using an awk command to pad zeroes. Unfortunately, the "|" pipe delimited character is gone when I tried to write the records to another file. awk -F \| ' {$1=sprintf("%06s", $1); print $0}' $CUSTFINAL2 > $CUSTFINAL3 BEFORE "KEYRECORD"|"SA ID"|"PER ID"|"SP ID"|"ACCT... (3 Replies)
Discussion started by: johnhips
3 Replies

7. Shell Programming and Scripting

trim spaces in unix for variable

HI Guys I have written a script using awk to split a file based on some identifier and renaming the file based on two values from specific length. ts a fixed width file. When I am trying to fetch the values a = substr($0,11,10) b = substr($0,21,5); i am getting spaces in a and b values .... (6 Replies)
Discussion started by: manish8484
6 Replies

8. Shell Programming and Scripting

awk - trim white space from a field / variable

Hi, Consider the data (FS = |): 1| England |end 2| New Zealand |end 3|Australia|end 4| Some Made Up Country |end 5| West Indies|end I want the output to be (i.e. without the leading and trailing white space from $2) England New Zealand Australia Some Made Up Country West... (4 Replies)
Discussion started by: Storms
4 Replies

9. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

10. UNIX for Beginners Questions & Answers

Views How to replace a CRLF char from a variable length file in the middle of a string in UNIX?

My sample file is variable length, with out any field delimiters. It has min of 18 chars length and the 'CRLF' is potentially between 12-14 chars. How do I replace this with a space? I still want to keep end of record, but just want to remove these new lines chars in the middle of the data. ... (7 Replies)
Discussion started by: chandrath
7 Replies
newpad(3XCURSES)					  X/Open Curses Library Functions					  newpad(3XCURSES)

NAME
newpad, pnoutrefresh, prefresh, subpad - create or refresh a pad or subpad SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> WINDOW *newpad(int nlines, int ncols); int pnoutrefresh(WINDOW *pad, int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol); int prefresh(WINDOW *pad, int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol); WINDOW *subpad(WINDOW *orig, int nlines, int ncols); PARAMETERS
nlines Is the number of lines in the pad to be created. ncols Is the number of columns in the pad to be created. pad Is a pointer to the pad to refresh. pminrow Is the row coordinate of the upper left corner of the pad rectangle to be copied pmincol Is the column coordinate of the upper left corner of the pad rectangle to be copied. sminrow Is the row coordinate of the upper left corner of the rectangle on the physical screen where pad is to be posi- tioned. smincol Is the column coordinate of the upper left corner of the rectangle on the physical screen where pad is to be posi- tioned. smaxrow Is the row coordinate of the lower right corner of the rectangle on the physical screen where the pad is to be positioned. smaxcol Is the column coordinate of the lower right corner of the rectangle on the physical screen where the pad is to be positioned. orig Is a pointer to the parent pad within which a sub-pad is created. DESCRIPTION
The newpad() function creates a new pad with the specified number of lines and columns. A pointer to the new pad structure is returned. A pad differs from a window in that it is not restricted to the size of the physical screen. It is useful when only part of a large window will be displayed at any one time. Automatic refreshes by scrolling or echoing of input do not take place when pads are used. Pads have their own refresh commands, pre- fresh() and pnoutrefresh(). The prefresh() function copies the specified portion of the logical pad to the terminal screen. The parameters pmincol and pminrow spec- ify the upper left corner of the rectangular area of the pad to be displayed. The lower right coordinate of the rectangular area of the pad that is to be displayed is calculated from the screen parameters (sminrow, smincol, smaxrow, smaxcol). This function calls the pnoutrefresh() function to copy the specified portion of pad to the terminal screen and the doupdate(3XCURSES) function to do the actual update. The logical cursor is copied to the same location in the physical window unless leaveok(3XCURSES) is enabled (in which case, the cursor is placed in a position that the program finds convenient). When outputting several pads at once, it is often more efficient to call the pnoutrefresh() and doupdate() functions directly. A call to pnoutrefresh() for each pad first, followed by only one call to doupdate() to update the screen, results in one burst of output, fewer characters sent, and less CPU time used. The subpad() function creates a sub-pad within the pad orig with the specified number of lines and columns. A pointer to the new pad structure is returned. The sub-pad is positioned in the middle of orig. Any changes made to one pad affect the other. touchwin(3XCURSES) or touchline(3XCURSES) will likely have to be called on pad orig to correctly update the window. RETURN VALUES
On success, the newpad() and subpad() functions returns a pointer to the new pad data structure. Otherwise, they return a null pointer. On success, the pnoutrefresh() and prefresh() functions return OK. Otherwise, they return ERR. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
clearok(3XCURSES), doupdate(3XCURSES), is_linetouched(3XCURSES), libcurses(3XCURSES), pechochar(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 newpad(3XCURSES)
All times are GMT -4. The time now is 04:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy