Advertisement

10.17.2007 at 06:27AM PDT, ID: 22898819
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

Trying to replace characters in a text file by position on line (not pattern or delimiter) in unix shell scripting

Asked by Nikola_Novak in KornShell (ksh), Unix Systems Programming, Regular Expressions

Tags: , , , ,

I am trying to develop a shell script on AIX 5.3.5 / ksh or ksh93, which will take a text file with fixed-length rows ('records'), and on each row replace certain characters, based on position, with spaces.
For example, I may want to replace characters 450 through 470 with 20 blank spaces.

Problem I've encountered is that most unix utilities are based on delimited fields, not position-defined fields. I've tried to cludge it in with regexes:
CTC_PS_BLANKCMD="sed s/^\(.\{$CTC_PS_BEG\}\)\(.\{$CTC_PS_LEN\}\)/\1$CTC_PS_SPACER/ $CTC_PS_SOURCE"

(where CTC_PS_BEG is the first character to be replaced, CTC_PS_LEN is the length, CTC_PS_SPACER is the string with spaces, and CTC_PS_SOURCE is the input file).
However, two problems: no matter how I play with quotes, interpreter/shell changes the number of spaces to single; more over, it only works for characters up to 255, because of AIX limit of RC_MAX_DUP which I cannot change - it only allows up to 255 matches of a regular expression.

What is the best way I can create a command that will replace characters based on position?Start Free Trial
[+][-]10.17.2007 at 06:35AM PDT, ID: 20093089

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.17.2007 at 06:41AM PDT, ID: 20093139

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 06:45AM PDT, ID: 20093186

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 06:47AM PDT, ID: 20093195

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 06:53AM PDT, ID: 20093272

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 06:57AM PDT, ID: 20093313

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 07:03AM PDT, ID: 20093403

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.17.2007 at 07:03AM PDT, ID: 20093406

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 07:07AM PDT, ID: 20093469

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 07:22AM PDT, ID: 20093619

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 07:28AM PDT, ID: 20093691

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 09:50AM PDT, ID: 20095000

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: KornShell (ksh), Unix Systems Programming, Regular Expressions
Tags: replace, file, text, character, position
Sign Up Now!
Solution Provided By: ahoffmann
Participating Experts: 3
Solution Grade: A
 
 
[+][-]10.17.2007 at 10:38AM PDT, ID: 20095390

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.17.2007 at 11:34AM PDT, ID: 20095828

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.17.2007 at 11:37AM PDT, ID: 20095849

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628