Sponsored Content
Top Forums Shell Programming and Scripting Replace specific column range in a non-delimited file with a string! Post 302840287 by navojit dutta on Monday 5th of August 2013 06:13:21 AM
Old 08-05-2013
Replace specific column range in a non-delimited file with a string!

Hi All, I will need an help with respect to replacing a range of columns on a non-delimited file using a particular string pattern.

Say file input is
Code:
MYNUMBERD000000-BAN CHUE INSNTS       **    N+
MYAREDSDD000000+BAN CHUE INSNTS       **    N+
MYDERFFFSD00000-GIR PENT - ACH            **    N+
MYDDDDDAY000000+GIR PENT - ACH            **    N+

I have to replace the part from "+" or "-" to "**" with a string say "TEST".
I am specifically unable to traverse to 16th column and then replace from column17 to column38 with the string using sed.

So output should be as below :
Code:
MYNUMBERD000000-TEST**    N+
MYAREDSDD000000+TEST**    N+
MYDERFFFSD00000-TEST**    N+
MYDDDDDAY000000+TEST**    N+

Thanks for any help on this.

Last edited by Scott; 08-05-2013 at 07:27 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace string in a file within a range of line

Hi, I want to replace the srting '; with ABCD'; in a file from line 1 to line 65. Is there any single command to do it without using awk Thanks for quick reply https://www.unix.com/images/misc/progress.gif (3 Replies)
Discussion started by: tosattam
3 Replies

2. UNIX for Dummies Questions & Answers

Search and replace string only in a particular column in a delimited file

I have file with multiple columns. Column values for a record may be same. Now i have to replace a column value(this can be same for the other columns) with new value. File.txt A,B,C,D,A,B,C,D,A,B,C,D A,B,C,D,A,B,C,D,A,B,C,D A,B,C,D,A,B,C,D,A,B,C,D A,B,C,D,A,B,C,D,A,B,C,D... (1 Reply)
Discussion started by: ksailesh
1 Replies

3. UNIX for Dummies Questions & Answers

Deleting lines that contain a specific string from a space delimited text file?

Hi, I have a space delimited text file that looks like the following: 250 rs10000056 0.04 0.0888 4 189321617 250 rs10000062 0.05 0.0435 4 5254744 250 rs10000064 0.02 0.2403 4 127809621 250 rs10000068 0.01 NA 250 rs1000007 0.00 0.9531 2 237752054 250 rs10000081 0.03 0.1400 4 17348363... (5 Replies)
Discussion started by: evelibertine
5 Replies

4. UNIX for Dummies Questions & Answers

Adding tags to a specific column of a space delimited text file

I have a space delimited text file with two columns. I would like to add NA to the first column of the text file. Input: 19625 10.4791768259 19700 10.8146489183 19701 10.9084026759 19702 10.9861346978 19703 10.9304364984 Output: NA19625 10.4791768259 NA19700 10.8146489183... (1 Reply)
Discussion started by: evelibertine
1 Replies

5. UNIX for Dummies Questions & Answers

how to print the column that contains a string in delimited file in unix

Hi Team, I have a requirement to print the column or find the column number of a particular string in delimited (;) file. Ex: aaa;bbb;ccc;rrr;mmm; gggg;rrr;mmmm;ssss;eee;aaa; ccc;gggg;tttt;bbbb;dddd;ggggg;rrr; my file contains 1000+ rows like above example with semicolon... (3 Replies)
Discussion started by: baskivs
3 Replies

6. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

7. UNIX for Dummies Questions & Answers

Search for a specific String in a log file for a specific date range

Hi, I have log file which rolls out every second which is as this. HttpGenRequest - -<!--OXi dbPublish--> <created="2014-03-24 23:45:37" lastMsgId="" requestTime="0.0333"> <response request="getOutcomeDetails" code="114" message="Request found no matching data" debug="" provider="undefined"/>... (3 Replies)
Discussion started by: karthikprakash
3 Replies

8. Shell Programming and Scripting

Replace pipe delimited column string to null

Hi All, I have a large dat file where each lines are pipe delimited values. I need to parse the file depending on the request. For example: sometimes I have told to remove all the values in the 7th column (this case remove values '3333' only from the first line and '3543' from the second line)... (4 Replies)
Discussion started by: express14
4 Replies

9. UNIX for Beginners Questions & Answers

Replace a column in tab delimited file with column in other tab delimited file,based on match

Hello Everyone.. I want to replace the retail col from FileI with cstp1 col from FileP if the strpno matches in both files FileP.txt ... (2 Replies)
Discussion started by: YogeshG
2 Replies

10. Shell Programming and Scripting

Replace delimiter for a particular column in a pipe delimited file

I have an input file as below Emp1|FirstName|MiddleName|LastName|Address|Pincode|PhoneNumber 1234|FirstName1|MiddleName2|LastName3| Add1 || ADD2|123|000000000 Output : 1234|FirstName1|MiddleName2|LastName3| Add1 ,, ADD2|123|000000000 OR 1234,FirstName1,MiddleName2,LastName3, Add1 ||... (2 Replies)
Discussion started by: styris
2 Replies
POLYGRAPH-POP-TEST(1)						   User Commands					     POLYGRAPH-POP-TEST(1)

NAME
polygraph-pop-test - predicts cache hit ratios for a given workload SYNOPSIS
pop-test [--option ...] OPTIONS
--help list of options --version package version info --out <file> redirect console output --cachable <%> portion of cachable replies --public_interest <%> portion of URLs shared among all robots --recurrence <%> probability of a re-visit to a URL --work_set_size <size> working set size --cache_size <size> cache size --obj_size <size> average object size --robots <int> total number of robots to simulate --pop_model <str> popularity model --sim_length <int> total number of request to simulate COPYRIGHT
Copyright (C) 2003-2006 The Measurement Factory, Inc. SEE ALSO
polygraph(7) - general information and a list of programs http://www.web-polygraph.org/ - project web site polygraph-pop-test - Web Polygraph February 2010 POLYGRAPH-POP-TEST(1)
All times are GMT -4. The time now is 04:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy