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
After Processing Expected output:-
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
Hi scottaazz,
thanks for you help on this.
But this solution is not working. You solution does replaces record 1 & 3 correctly but changes overall formatting & position of the record no. 1 & 3. i.e 0-1234567890 with 01234567890- and 00-456789012 with 00456789012-.
Please see the attached files source before your command execution and after your command execution.
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 Input processing
1) 1st Record positions 351-357 = 0-12345
2) 3rd Record positions 351-357 = 00-4567 Expected output processing:-
1) 1st Record positions 351-357 = 012345-
2) 3rd Record positions 351-357 = 004567-
Total length of record is 413.
Hi scottaazz,
thanks for you help on this.
But this solution is not working. You solution does replaces record 1 & 3 correctly but changes overall formatting & position of the record no. 1 & 3. i.e 0-1234567890 with 01234567890- and 00-456789012 with 00456789012-.
Please see the attached files source before your command execution and after your command execution.
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 Input processing
1) 1st Record positions 351-357 = 0-1234567890
2) 3rd Record positions 351-357 = 00-456789012 Expected output processing:-
1) 1st Record positions 351-357 = 01234567890-
2) 3rd Record positions 351-357 = 00456789012-
Total length of record is 413.
Don't understand your output result sample...
you are telling to replace 357th position with "-".
lets consider your sample with their positions in square bracket: [351]0-1234[357]567890
so output should be : 012345-67890
and not what you have mentioned : 01234567890-......correct me if am wrong...
Thanks MSABHI You provided solution worked fine. UDAMAN.
Sorry for the typo on which i corrected now. Input processing
1) 1st Record positions 351-357 = 0-12345
2) 3rd Record positions 351-357 = 00-4567 Expected output processing:-
1) 1st Record positions 351-357 = 012345-
2) 3rd Record positions 351-357 = 004567-
Thanks Buddy.
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)
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)
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)
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)
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)
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)
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)
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)
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)