I have a file with a succesion of records like this:
I would like to replace the line starting with =856 with different values
first value will be, the first value of the fields 952 $a and $b => this one \\$aBNCSMAJ\\$bBNCSMAJ
Then a fix value (always the same) => $yEJNL
And at the end, this two values also picked from 952 field:
\\$oBNCSMAJ0000001\\$pBNCSMAJ0000001
As a resulta the entire record will be:
I hope there is a way to do this.
Thanks a lot for any help
Hi
Thanks a lot for this script.
I try it with a sample and here is the result:
First, if I redirect to a new file I have this:
Not sure it's a problem, then if you look the new file:
You see this
The exact result should be this:
The difference is is 856 field there is the 952 field too...Not good
Is it possible to change this?
Thanks again for all the effort
---------- Post updated at 10:06 AM ---------- Previous update was at 08:15 AM ----------
Hi Alister
yes I'll give here some explication, sorry not be enougth clear in my last posts.
So the file is a succesion of records.
Each record starts with this field:
And the into each record you'll see a lot of =xxx codes
The code I want to change are =856 and =866
All this lines starting with =856 and =866 code may be change to be =952
But, the traitment is not the same if we have =866 or =856
The =866 case is resolve with some nice nawk command given yesterday:
As you see, this command line just change the =866 code
The =856 code is different because the data are not present in the line, it can not be catched with awk pointing to the write column.
The data are spraid between new =952 code
So the way I change is:
apply the
command line
After this step, I have a new file with =952 for all the occurence of =866 code.
I have a 3 step which be modify the =856
All the fileds in a same line are separated bu \\$letter
letter could be any letter in the alphabet, in my case we have \\$a \\$b \\$y \\$h \\$o and \\$p
The code posted just earlier in good but just whit one duplication:
It change fine the =856 code, but add =952 in the same line..That is not write.
The entire file is very long, so here I'll send just a sample and after the resulta I would like to have:
Original sample:
After applying the first step I have:
(you will see the field 856 only because 866 have been changed)
The final result have to be the same but the field =856 must be like this (I just paste here the part)
With the current script, there is a =952 filed duplicated into the =856 code..This is the problem.
Hope consistent this time
Woops. I must've deleted my post while you were writing that response. I apologize for that.
After posting, I noticed that the data wasn't necessarily inconsistent (if one assumes that the input is space delimited and that the =952 line in the input of post #3 consists of a single column).
As far as I can tell, I can't undelete the post to restore my part in the thread.
The least I can do is try to help you out.
Reading your response now...
... sorry, but I'm not quite sure what to make of it. I'll give it another look later in the day.
- In the first post the sample input data is different from your second post. In the first post, line beginning with '=952' has string separated by spaces, but not in your second post.
- In you second post you indicate that output should be something like:
while in your first post you indicate to add '$yEJNL' after the second field. However in this example appears at the end. Which is correct?
- Finally, in the first post you indicate to add the last two fields of line '=952' in line '=856', however in the second post you add more fields besides these two.
In short, perhaps I misunderstood your question but I am very confused with your examples. If you change data and specifications it is obvious that my script won't work.
Hi All,
I have data like below
1 CREATE TABLE temp123
2 (
3 col1 INTEGER,
4 col2 CHAR(3) CHARACTER SET LATIN NOT CASESPECIFIC,
5 col3 DECIMAL(19,0),
6 col4 VARCHAR(80) CHARACTER SET LATIN NOT CASESPECIFIC,
7 start_dt DAte FORMAT 'YY/MM/DD',
8 end_dt DATE FORMAT 'YY/MM/DD',
9 datecol1... (6 Replies)
i am having a file test1.txt and its contents is as follows.
<abcaaa bbb ccc ddd>
<dddeeeffff>
<my computer>
<abcmydocuments>
Now I need to find the text abc and should be replaced as follows.
<abc>
<dddeeeffff>
<my computer>
<abc>
First line has the text "abc" and it has to be... (3 Replies)
I have the following requirement in the shell script
1. I have more than 200 shell script files. I need to find out how many shell scripts have "sqlplus /" in the shell file
2. I need to replace all the shell scripts in the single command
for example: connect scott/scott
replace as ... (6 Replies)
Dear All
To find a file, according to you, I tried as:
#find / -name file-name -print
To find a string inside the files , I tried as :
#find / -name "*" |xargs grep "string"
Can you please let me know how can I try for find/replace (i.e.
finding the intended string inside the text files... (6 Replies)
Need to convert
echo "7 6"
to
$7,$6
But the count of numbers can increase say echo "7,6,8,9" tried this didn't work
echo "7 6" | sed 's/\(*\)/\1/'
But did not help much (3 Replies)
I am looking to find and replace a string in a file, can anyone suggest a global find and replace. looked at previous replies on other queries but none seem to address what i am looking for. aint familiar with sed so trying to use ordinary unix commands if possible
Thanks in advance (2 Replies)
hi,
i have a data in a file like below:
100 8388kmn844., 8488
200 8398kmn894., 8398
i want replace from kmn to . as null.
output should be
100 8388, 8488
200 8398, 8398
Plz help.
Thanks in advance (1 Reply)
Hi,
There are some "n" files in a directory which contains comman string.A command to find and replace the string in all the files without looping.
like if i am in a directory :
# find ./ -name ".txt" | xargs sed -e 's/test/tst'
Upto here is performed correctly and i want to... (4 Replies)
Hi
I am trying to find a product code hightlighted in red, and re-insert it at another place on the same file. I shall be grateful if anyone can help me with this. Stuck and have deadline!!:confused:
Original Line: (I can get source data in one of these two formats)
ISD=977155185403901+DIE... (2 Replies)
I have statement like this
column_id.columnname=="value"
in unix i want to modify above statement to
variable1=="value"
that means i have to replace the string before "==" by string "variable1"
second catch is, in statement instead of "==" you can have any arithmatic comarision... (7 Replies)