How can I change the comma sign (,) to plus sign (+) with the sed command or any regex?
I mean to change only the comma that beteen the quotation marks.
Could you please try following and let me know if this helps.
Output will be as follows.
Also I have tested above command with your provided sample Input_file only which is having , as a field separator. Kindly post more details with exact sample expected output in case of any queries.
How can I change the comma sign (,) to plus sign (+) with the sed command or any regex?
By using the s-subcommand. I suggest reading the man page of sed and - if you are stuck - ask specific questions once they arise.
There are several good introductions to pattern matching here (for instance: here is one) and i suggeest you use the search function of the forum and see where it takes you.
If you need help with sed in general there are several good books (notably Dale Dougherty's phantastic "sed & awk") as well as countless threads about the specifics here.
How can I change the comma sign (,) to plus sign (+) with the sed command or any regex?
I mean to change only the comma that beteen the quotation marks.
You can do the whole thing from just sed alone.
First make sure the line contains two quotes, if not you don't want to perform this next code.
The h copies the line to hold space.
First s deletes everything outside the quotes, the next s makes your comma to plus sign change.
The G appends the hold space to pattern space, separated by new-line (\n).
The last s identifies the original pattern space as group 1, after the new line before the first quote is group 2, stuff originally between quotes is ignored (it's fixed and in group 1 now)--that also throws away the quotes, and stuff after the last quote is group 3. The groups are played back in 2, 1, 3 order and the quotes are reinserted on either side of group 1.
The requirement is i need to find an array value matching with pattern {5:{ , replace that with 5: and reassign that to same array index and print it.
I write something like below and the issue is sed command is not working. If i replace " with "`" the script gives syntax error.how can i... (8 Replies)
Hi All,
I want to change the name as SEQ_13
ie., <Property Name="Name">SEQ_13</Property>
when the Stage Type is PxSequentialFile
ie., <Property Name="StageType">PxSequentialFile</Property> :wall:
Input.XML
<Main>
<Record Identifier="V0S13" Type="CustomStage" Readonly="0">... (3 Replies)
hello everybody,
I have a group of file
eg-
sample1
sample2
sample3
sample4
each file contain this :-
cat sample1
SEQ_NUM,1,UPESI1
My requirement is to
change the value-UPESI1 to UPE10 in file which contain this pattern -UPESI1.
any help is appreciated. (2 Replies)
Hello,
I have a text file that i want to redirect into a new file , searching and replacing certain string during the opertaion.
This should be done using shell script , so it should not be interactive.
The script should get four parameters :
source file
target file
source string
target... (1 Reply)
Hi,
I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file.
For Example:
If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained.
But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
Hello,
The following sed command is giving error
sed: -e expression #1, char 13: unknown option to `s'
The sed command is
echo "//-----" | sed "s/\/\/---*/$parChk/g"
where parChk="//---ee-"
How can i print the variable value from sed command ?
And is it possible to replace a... (2 Replies)
Please Help... I am trying to manipulte the following line
Before :
<user:Account_Password>002786</user:Account_Password>
the password is the "variable", i need to delete / omit the password in the file, (it occurs several thousand times)
so the tag line looks like
After:... (4 Replies)
i am substituting some text in the xml file using sed, on shell directly it works fine, but when i run it inside script file, it say, the function cant be parsed, i think the prob is due to xml file, kindly help (4 Replies)