I have been looking at the file structure:
1) All lines start with the " ", single space, character as an absolute minimum, are these indents and need to be preserved?
2) If so then line 1 is shifted 2 out of 3 " "'s, 2 spaces, leftwards on the output which implies "NO" to number 1)
3) If indentation IS required then you need to remove <!-- <- note the TRAILING space.
4) Similarly the other end --> <- again note the LEADING space.
5) And leave the 2 lost spaces intact in the first output line.
Just an observation that caught my attention...
Last edited by wisecracker; 03-29-2018 at 06:42 AM..
Reason: Add number 5)
This User Gave Thanks to wisecracker For This Post:
Your explanation is awesome,...I understand now, what makes me confuse before was, I remember to do a backlash to any special character, But in the command below, theres none.
Thanks
---------- Post updated at 08:52 AM ---------- Previous update was at 08:51 AM ----------
Quote:
Originally Posted by RudiC
I like your explanation,. i understand the syantax because of you. But pelase educate me, when to use a backslash to negate a special character?
Thanks
But pelase educate me, when to use a backslash to negate a special character?
The rule is: when you use a character that has a special meaning (to sed) and you want it to mean just the character itself you need to "escape" it - that is, prepend it with a backslash.
An example:
The dot (".") here doesn't mean a dot, but is a special character, meaning "any one character". If you want it to mean a real, literal dot and nothing else, you need to escape it:
Notice that this escaping is implicit in some situations, for instance in "character-classes". Look at the following regular expression:
This searches for an "a", followed by either an "b", a "c" or a "d", followed by an "e". It would match any of these strings:
abe
ace
ade
Inside the brackets all characters lose their special meaning. I.e. a[bc.]d would search for any of these strings:
abd
acd
a.d
If you would try to escape a character here the escaping backslash would be treated as a normal character too. The regexp a[bc\.]d would find these strings:
abd
acd
a\d
a.d
Notice that the characters you called special - "<", ">", etc. - don't have any special meaning in sed anyway and would have been safe to use without any escaping in first place.
backslashes don't negate characters, they "escape" them, i.e. remove their special meaning, force them back to normal chars. Negate, BTW, is a difficult term with characters. You might mean "complement"?
Hi,
I have a file in unix with 15 columns.It consists special characters(#,$,^M,@,*,% etc)at the end of the each record.I want to remove these special characters.I used the following:
Sed -e 's/ /g;s/ */ /g'
. But It is removing special characters exists everywhere in the file(begining,middle... (24 Replies)
Hello gurus,
I have a lookup table
cat tmp1
\\\erw``~ 1
^774574574565665f\] 2
()42543^
and I`m trying to compare a bunch of strings such that, either the lookup table column 1, or the string to be looked up are substrings of each other (and return the second lookup column if yes).
... (2 Replies)
i need to replace the any special characters with escape characters like below.
test!=123-> test\!\=123
!@#$%^&*()-= to be replaced by
\!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Hi all,
I was wondering how can i see the special characters like \t, \n or anything else in a file by using Nano or any other linux command like less, more etc (6 Replies)
Hello Team,
Any one suggest how to delte the below special character from a file which is having one column 10 rows of same below content.
----------------------------------------
Kosten|bersicht gemd_ ' =Welche Kosten kvnnen... (2 Replies)
When I open a file in vi, I see the following characters:
\302\240
Can someone explain what these characters mean. Is it ASCII format? I need to trim those characters from a file.
I am doing the following:
tr -d '\302\240'
---------- Post updated at 08:35 PM ---------- Previous... (1 Reply)
Hi all,
I have the following lines
<b>A gtwrhwrthwr text hghthwrhtwrtw </b><font color='#06C'>; text text (text)
<b>B gtwrhwrthwr text hghthwrhtwrtw </b><font color='#06C'>; text text (text)
<b>J gtwrhwrthwr text hghthwrhtwrtw </b><font color='#06C'>; text text (text)
and I would like to... (5 Replies)
I don't now exactly how I did it, but I created a file named " -C "
cexdi:/home1 $ls -lt
total 1801336
-rw------- 1 cexdi ced-group 922275840 23 mars 10:03 -C
How do I delete this file ?
cexdi:/home1 $rm -C
rm: invalid option -- C
Syntax : rm filename ...
Doesn't work...... (5 Replies)