Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a .c file where I want to replace all occurrences of /*abc*/ with xyz. How do I do that in Vim?
Vim allows you to use other characters than / when substituting, so e.g. :%s#/abc/#xyz#g makes it easier when you have / as part of the pattern you're looking for.
If you want replace "/*abc*/" with "xyz", go to command mode and:
:%s/\/\*abc\*\//xyz/g
Note that "/" and "*" must be escaped.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 19 days ago.
The community reviewed whether to reopen this question 19 days ago and left it closed:
Duplicate This question has been answered, is not unique, and doesn’t differentiate itself from another question.
Improve this question
All is in the title!
I have a file with plenty of lines (these are paths to file).
Some lines, listing directories, end with the character /: I want to remove it.
Thanks!
Here the solution:
sed -ri 's:/$::g' <FILE_NAME>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 months ago.
Improve this question
I have a SED Command in a code and I need to understand what its actually doing ?
Below is what I see in code ?
show partitions {curr_table}' | sed 's/[\t]/,/g' > /tuber/dag_run_ctx/tbl_qc.csv;
Any idea what would the above Sed command do?
Replace or substitute each occurrence of <TAB> character represented as \t with , character.
And save the output into file: /tuber/dag_run_ctx/tbl_qc.csv
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
For example, I have a string like this
a = "starlight sunlight"
And I want to change it into
a = "starspot sunspot"
well i guessed you writing this in python so you can use the replace method
enter example
in your case you went to replace the word light with the word spot so just write
a=a.replace("light","post")
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Need help on below requirement.
I have a file with list of URLs and need to mask query param values as shown in below example in Linux.
http://hostname:port/uri?data=value&data1=value2&data3=value3
to
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
thanks
you could replace any character that is not a &, it is more efficient than enumerating all possible ranges:
$ echo 'http://hostname:port/uri?data=value&data1=va%20lue2&data3=value3' | \
sed -r 's/=[^&]+/=XXX/g'
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want to search for a number in string that does not occur between numbers.
For example:
string="10003096,10007051,10003098,10007053,10000952,10002696,10003619,900004608"
If i search for 10003096, then it exists.
But if i search for 1000, then it means it does not exist.
Even if i search for 10000952,10002696, then it means it does not exist.
How can i write the shell script for this?
Please help.
I have tried various options with grep and sed but it does not help.
Pad both your 'needle' and 'haystack' with commas. E.g.
echo ",$string," | grep ",10007053,"