Sponsored Content
Top Forums Shell Programming and Scripting Reformat a string and pad space at the end Post 302583394 by menglm on Tuesday 20th of December 2011 10:26:31 AM
Old 12-20-2011
Question Reformat a string and pad space at the end

I need to read in the string from input file and reform it by cut each segment and check the last segement lenght. If the last segment length is not as expected (see below segment file or table. It is predefined), then pad enough space.


Old string
FU22222222CA6666666666AKxvbFMddreeadBP999
new string
FU22222222CA6666666666AKxvbFMddreead
BP999 &&


Segment table
id length
-----------------
FU 10
CA 12
AK 5
FM 9
BP 20

Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how can I read the space in the end of line

cat file1|while read i do echo "$i"|wc done with this command the space in the end of the line not considered how can solve that for example: read h "hgyr " echo "$h"|wc 4 (2 Replies)
Discussion started by: Ehab
2 Replies

2. Shell Programming and Scripting

Appending string, variable to file at the start and string at end

Hi , I have below file with 13 columns. I need 2-13 columns seperated by comma and I want to append each row with a string "INSERT INTO xxx" in the begining as 1st column and then a variable "$node" and then $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13 and at the end another string " ; COMMIT;" ... (4 Replies)
Discussion started by: Vaddadi
4 Replies

3. UNIX for Dummies Questions & Answers

removal of space from the end

HI, I need the help from the experts like I have created one file with text like: Code: a b c de f g hi j k l So my question is that i have to write the script in which like in the first sentence it will take only one space after d and remove all the extra space in the end.I dont... (0 Replies)
Discussion started by: bhanudhingra
0 Replies

4. Shell Programming and Scripting

Pad Zeros at the end

I have number/strings like below input =23412133 output = 234121330000 (depends on the number give at runtime) i need to padd zeros based on runtime input . i tried below printf ' %d%04d\n', "23412133"; But the precision 4 is static here how can i pass this as runtime input. i am... (11 Replies)
Discussion started by: greenworld123
11 Replies

5. Shell Programming and Scripting

Pad space at the end of string and reformat

I need to read in the string from input file and reform it by cut each segment and check the last segement lenght. If the last segment length is not as expected (see below segment file or table. It is predefined), then pad enough space. Old string FU22222222CA6666666666AKxvbFMddreeadBP999... (11 Replies)
Discussion started by: menglm
11 Replies

6. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

7. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

8. Shell Programming and Scripting

Putting white Space at the end of the string

Hi Guys, Hope, you all are doing good out there. I am writing a shell script and currrint in need of your help. This is what I need to do; I have position based plain file. One of the fields is 15 character long. I need to fill that field. The problem is that the value is dynamic, it could... (4 Replies)
Discussion started by: singh.chandan18
4 Replies

9. Shell Programming and Scripting

How to pad zeroes based on input string?

Hello everyone, I am comparing two floating point numbers by storing them in seperate files and then using difference command to verify,it is working fine. But I want to compare two values which will come at 4 precision places. ex: file1 Date,Count,Checksum... (7 Replies)
Discussion started by: karthik adiga
7 Replies

10. Shell Programming and Scripting

Gawk --- produce the output in pattern space instead of END space

hi, I'm trying to calculate IP addresses and their respective calls to our apache Server. The standard format of the input is HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST... (2 Replies)
Discussion started by: busyboy
2 Replies
LFS_SEGWAIT(2)						      BSD System Calls Manual						    LFS_SEGWAIT(2)

NAME
lfs_segwait -- wait until a segment is written LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> int lfs_segwait(fsid_t *fsidp, struct timeval *tv); DESCRIPTION
lfs_segwait() blocks until a new segment is acquired for writing by the filesystem specified by *fsidp or if *fsidp is -1, until a segment is acquired for writing by any LFS filesystem. If timeout is non-zero, lfs_segwait() will return after timeout milliseconds regardless of whether a new segment has been designated for writing or not. RETURN VALUES
lfs_segwait() returns 0 if a new segment was acquired; 1 if it timed out; or -1 on error. ERRORS
An error return from lfs_segwait() indicates: [EFAULT] fsidp points outside the process's allocated address space. [EINTR] A signal was delivered before the time limit expired and before a new segment was designated for writing. [EINVAL] The specified time limit is negative. SEE ALSO
lfs_bmapv(2), lfs_markv(2), lfs_segclean(2), lfs_cleanerd(8) HISTORY
The lfs_segwait() function call appeared in 4.4BSD. BSD
May 23, 2000 BSD
All times are GMT -4. The time now is 08:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy