[^]]* that means all characters but "]" zero or more times. \[[^]]*\] on "[brackettext1] some other text [brackettext2] some different text"
will find "[brackettext1]"
but \[.*\]
will find "[brackettext1] some other text [brackettext2]"
And to keep the bracket text:
I know that [ expression ] in regexp means that: match the expression .
And the ^ in expression means "not include".
My question is:
1. If Metacharacter appears within [ expression ] , which means the character itself, for example, in \[[^]]*\], why does it not neccessary need to be escaped? Is it a common rule?
2. echo 'hgfd[xtd] 123' | sed -E 's/\[([^]]*)\]/\1/', what does -E means?
3. If I want to delete all the "[" and "]" like this: just match "[" or "]" and replace it with "", the code like sed s; [ [ ] ] ;; . It doesn't work. how to modify?
To put it simple.
Source string: abc[[4545[]]]adfd[[[[asfdsfsf[][[[][][asdf. I want to delete all the "[" and "]"
4. vgersh99's code.echo 'hgfd[xtd] 123' | sed 's/\[[^]]*\]//1', what does the last number: 1 means?
Thanks a lot.
I know that [ expression ] in regexp means that: match the expression .
And the ^ in expression means "not include".
My question is:
1. If Metacharacter appears within [ expression ] , which means the character itself, for example, in \[[^]]*\], why does it not neccessary need to be escaped? Is it a common rule?
because sed knows how to deal with 'nested' '[]'.
Quote:
Originally Posted by painless
2. echo 'hgfd[xtd] 123' | sed -E 's/\[([^]]*)\]/\1/', what does -E means?
'-E' - is for Extended Regex (in some sed implementations.
Quote:
Originally Posted by painless
3. If I want to delete all the "[" and "]" like this: just match "[" or "]" and replace it with "", the code like sed s; [ [ ] ] ;; . It doesn't work. how to modify?
To put it simple.
Source string: abc[[4545[]]]adfd[[[[asfdsfsf[][[[][][asdf. I want to delete all the "[" and "]"
echo ' abc[[4545[]]]adfd[[[[asfdsfsf[][[[][][asdf' | sed 's/[][]//g'
Quote:
Originally Posted by painless
4. vgersh99's code.echo 'hgfd[xtd] 123' | sed 's/\[[^]]*\]//1', what does the last number: 1 means?
Hello,
I could not remove brackets with text contents
myfile:
Please remove the bracket with text
I wish to remove:
I tried:
sed 's/\//' myfile
It gives:
Please remove the bracket with text A1
I expect:
Please remove the bracket with text
Many thanks
Boris (2 Replies)
hello Friend,
In hostgroup file, i have define lots of hostgroups. I need to remove few of them without manually editing file. Need script or syntax.
I want to search particular on hostgroup_members and delete hostgoup defination of it.
for example.
define hostgroup{
hostgroup_name... (8 Replies)
Gents,
Is there the chance to remove part of the file,
Taking in consideration this condition.
For each record the first row start with the string % VE
should be 56 rows for each records..
first row = % VE
last row = % sw
total 56 rows for each record.
Then in the case that the... (4 Replies)
Hi all
This time my input conatin 3 columns:
ERCC1 (PA155) Platinum compounds (PA164713176) Allele A is not associated with response to Platinum compounds in women with Ovarian Neoplasms as compared to allele C .
CES1 (PA107) methylphenidate (PA450464) Genotype CT is not... (4 Replies)
Can somebody tell me the difference between double brackets and single
brackets, when doing a test.
I have always been acustomed to using single brackets and have not
encountered any issues to date. Why would somebody use double brackets.
Ie
if ]
vs
if
Thanks to... (2 Replies)
I have a file in below format (pipe delimited):
1234__abc|John__abc|xyz
3345__abc|Kate__abc|xyz
55344|Linda__abc|xyz
33434|Murray|xyz
I want to remove any occurence of "__abc" in the second field of this file.
I did some research and found a way to replace the entire second field with... (5 Replies)
Hi
I need some help with using shell script to analyze the content of a file. I hope someone can help me.
I have a file with content like the following:
/foldera/database/procedure/a.proc$$/version1/2
/folderb/database/procedure/proj1/b.proc$$/version2/2
I need to write a shell script to... (16 Replies)
I have an xml file, from where I need to take out Application2 entries and keep the others. I need to remove from <product> to </product> and the key element to look for while removing should be <application> as other pairs can be same for others.
<product>
... (10 Replies)
Hi,
Is it possible to remove the first part of the file name using find.
i.e i have something like 2006abc.txt , 1007bed.txt etc,
I wanna rename them to abc.txt , bed.txt
I tried some stupid way..
find . -name '*.txt' -exec mv {} `cut -f2-5 -d"_" {}` \;
somehow iam not getting it.
... (3 Replies)