Sponsored Content
Top Forums Shell Programming and Scripting Remove dashes if exist between positions 351-357 and then add - at the 357th position Post 302708891 by lancesunny on Tuesday 2nd of October 2012 11:23:50 AM
Old 10-02-2012
Remove dashes if exist between positions 351-357 and then add - at the 357th position

I need to remove dash (i.e. -) if present from positions 351-357, and then add - (dash) at 357th position. For example in following first and 3rd record we got
Before processing
1) 1st Record positions 351-357 = 0-12345
2) 3rd Record positions 351-357 = 00-4567
After processing:-
1) 1st Record positions 351-357 = 012345-
2) 3rd Record positions 351-357 = 004567-
Total length of record is 413.

Here is the example of the 4 records:- Before Processing
Code:
B123456Aero 12345678901234-1234 abcd Abcdef 1234 Abc Rd Ste 1 Abc Treak WI12345 0000123 0-12345 000000000
B223456Bero 09876543214321-2345 abcd Abcdef 1234 Abc Rd Ste 1 Abc Treak WI12345 0000123 0023456 000000000
B323456Cero 23456789012345-3236 abcd Abcdef 1234 Abc Rd Ste 1 Abc Treak WI12345 0000123 00-456 000000000
B423456Dero 32345678901234-4237 abcd Abcdef 1234 Abc Rd Ste 1 Abc Treak WI12345 0000123 0045678 000000000

After Processing Expected output:-
Code:
B123456Aero 12345678901234-1234 abcd Abcdef 1234 Abc Rd Ste 1 Abc Treak WI12345 0000123 012345- 000000000
B223456Bero 09876543214321-2345 abcd Abcdef 1234 Abc Rd Ste 1 Abc Treak WI12345 0000123 0023456 000000000
B323456Cero 23456789012345-3236 abcd Abcdef 1234 Abc Rd Ste 1 Abc Treak WI12345 0000123 004567- 000000000
B423456Dero 32345678901234-4237 abcd Abcdef 1234 Abc Rd Ste 1 Abc Treak WI12345 0000123 0045678  000000000

I also attached sample input file containing these records.
any help on this will be appreciated.
Thanks in advance.

Last edited by lancesunny; 10-02-2012 at 05:13 PM.. Reason: code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If doc file exist remove

I need help running a script. I have the script looking into a folder and converting .doc files to .odt. The script works fine except that I want it to only run when .doc files are present. If I can do this then I can put .xls files and .ppt files in the folder and convert them when they are... (2 Replies)
Discussion started by: handband2
2 Replies

2. Shell Programming and Scripting

how can i remove comments in random positions in a file?(bash)

Suppose i have a file like this: #bla bla #bla bla bla bla bla Bla BLA BLA BLA #bla bla .... .... how can i remove all comments from every line,even if they are behind commands or strngs that are not comments? any idea how i could do that using awk? (2 Replies)
Discussion started by: bashuser2
2 Replies

3. Shell Programming and Scripting

Search and remove digits (if exist) from end of the string

Hi Experts, Here is what I am trying to do. 1) say I have a file with below strings database1 database2 database3 data10gdb1 data10gdb2 databasewithoutdigit 2) I want to get the below output. (- if there is any digit at the end of the string, I need to remove it) (- Any... (3 Replies)
Discussion started by: shail_boy
3 Replies

4. Shell Programming and Scripting

awk script replace positions if certain positions equal prescribed value

I am attempting to replace positions 44-46 with YYY if positions 48-50 = XXX. awk -F "" '{if (substr($0,48,3)=="XXX") $44="YYY"}1' OFS="" $filename > $tempfile But this is not working, 44-46 is still spaces in my tempfile instead of YYY. Any suggestions would be greatly appreciated. (9 Replies)
Discussion started by: halplessProblem
9 Replies

5. Shell Programming and Scripting

Remove text from n position to n position sed/awk

I want to remove text from nth position to nth position couple of times in same line my line is "hello is there anyone can help me with this question" I need like this ello is there anyone can help me with question 'h' is removed and 'this' removed from the line. I want to do this... (5 Replies)
Discussion started by: elamurugu
5 Replies

6. Shell Programming and Scripting

Code to remove files when corresponding file doesnt exist isnt working.

I am trying to add some code to the begging of a script so that it will remove all the .transcript files, when their is no coressponding .wav file. But it doesnt work. This is the code I have added: for transcriptfile in `$voicemaildir/*.transcript`; do wavfile=`echo $transcriptfile | cut -d'.'... (2 Replies)
Discussion started by: ghurty
2 Replies

7. Shell Programming and Scripting

Remove words from file2 that don't exist in file1

Hi I have to list of words file1 and file2, I want to compare both lists and remove from file2 all the words that don't exist in file1. How can I do this? Many thanks (4 Replies)
Discussion started by: noliveira
4 Replies

8. Shell Programming and Scripting

Replace dashes positions 351-357 & 024-043 with 0 & replace " " if exis with 04 at position 381-382

I need to replace dashes (i.e. -) if present from positions 351-357 with zero (i.e. 0), I also need to replace dash (i.e “-“) if present between position 024-043 with zero (i.e. 0) & I replace " " (i.e. 2 space characters) if present at position 381-382 with "04". Total length of record is 413.... (11 Replies)
Discussion started by: lancesunny
11 Replies

9. Shell Programming and Scripting

Remove line break at specific position

Hi, I need to remove line breaks from a file, but only the ones at specific position. Input file: this is ok this line is divided at posit ion 30. The same as this one, also position 30 the rest of lines are ok with different lengths The longest ones are always s plitted at same... (15 Replies)
Discussion started by: qranumo
15 Replies
Xapian::PositionIterator(3pm)				User Contributed Perl Documentation			     Xapian::PositionIterator(3pm)

NAME
Search::Xapian::PositionIterator - Iterate over sets of positions. DESCRIPTION
This iterator represents a stream of positions for a term. It overloads "++" for advancing the iterator, or you can explicitly call the "inc" method. This class also overloads "eq", "ne", "==", "!=", "" (stringification) and "0+" (conversion to an integer). METHODS
new Constructor. Defaults to an uninitialized iterator. clone inc Advance the iterator by one. (Called implictly by "++" overloading). skip_to <termpos> Skip the iterator to term position termpos, or the first term position after termpos if termpos isn't in the list of term positions being iterated. equal <term> Checks if a term is the same as this term. Also overloaded to the "eq" and "==" operators. nequal <term> Checks if a term is different from this term. Also overloaded to the "ne" and "!=" operators. get_termpos Return the term position the iterator is currently on. Also implemented as conversion to an integer. get_description Return a description of this object. Also implemented as stringification. SEE ALSO
Search::Xapian,Search::Xapian::Document perl v5.14.2 2012-05-09 Xapian::PositionIterator(3pm)
All times are GMT -4. The time now is 01:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy