This could be done with sed by splitting the lines with extra spaces into three lines, deleting the spaces in the 2nd line of each split set, and rejoining the split lines into single lines again. I find awk to be easier to use for operations like this:
If you want to see how this script splits lines, removes spaces from the middle part, and rejoins lines; remove the octothorp (#) characters in front of the debugging printf() calls. (Once you see how it works, you can remove those lines entirely.)
If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk.
This User Gave Thanks to Don Cragun For This Post:
Hello,
I have the following to remove spaces from beginning and end of a string.
infile=`echo "$infilename" | sed 's/^ *//;s/ *$//`
How do I modify the above code to remove spaces from beginning, end and in the middle of the string also.
ex:
... (4 Replies)
Hi,
I need a help in deleting extra spaces in a text.
I have a huge file, a part of it is :-
3 09/21/08 03:32:07 started undef mino Oracle nmx004.wwdc.numonyx.com Message Text : The Oracle session with the PID 1103 has a CPU time ... (6 Replies)
Hello and thx for reading this
I'm using sed to remove only the leading spaces in a file
bash-280R# cat foofile
some text
some text
some text
some text
some text
bash-280R#
bash-280R# sed 's/^ *//' foofile > foofile.use
bash-280R# cat foofile.use
some text
some text
some text... (6 Replies)
if the answer is obvious, sorry, I'm new here.
anyway, I'm using tr to encrypt with rot-13:
echo `cat $script | tr 'a-zA-Z' 'n-za-mN-ZA-M'` > $script
it works, but it removes any consecutive spaces so that there is just one space between words. I've had this problem before while using sed to... (5 Replies)
Hi all,
i am getting count from oracle 11g by spooling it to a file.
Now there are some newline characters and blank spaces i need to remove these.
pl provide me a awk/sed solution.
the spooled file is attached.
i tried this.. but not getting req o/p (6 Replies)
Hi, suppose I have the following data:
albert music=top40 age=20
bob music=punk rock age=25
candy music=r n b age=22
dave music=mozart or bach only age=30
I want to extract and manipulate the music column but it's got spaces in it. How can I substitute the space with an underscore... (2 Replies)
The following command works echo "some text with spaces" | sh -c 'sed -e 's/t//g''But this doesn't and should echo "some text with spaces" | sh -c 'sed -e 's/ //g''Any ideas? (3 Replies)
Discussion started by: Tribe
3 Replies
LEARN ABOUT DEBIAN
mojomojo::formatter::wiki
MojoMojo::Formatter::Wiki(3pm) User Contributed Perl Documentation MojoMojo::Formatter::Wiki(3pm)NAME
MojoMojo::Formatter::Wiki - Handle interpage linking.
DESCRIPTION
This formatter handles intra-Wiki links specified between double square brackets or parentheses: [[wiki link]] or ((another wiki link)). It
will also indicate missing links with a question mark and a link to the edit page. Links can be implicit (like the two above), where the
path is derived from the link text by replacing spaces with underscores (<a href="wiki_link">wiki link</a>), or explicit, where the path is
specified before a '|' sign:
[[/explicit/path|Link text goes here]]
Note that external links have a different syntax: [Link text](http://foo.com).
METHODS
format_content_order
Format order can be 1-99. The Wiki formatter runs on 10.
strip_pre
Replace <pre ... with a placeholder
reinsert_pre
Put pre and lang back into place.
format_content
Calls the formatter. Takes a ref to the content as well as the context object.
format_link <c> <wikilink> <base> [<link_text>]
Format a wikilink as an HTML hyperlink with the given link_text. If the wikilink doesn't exist, it will be rendered as a hyperlink to an
.edit page ready to be created.
Since there is no difference in syntax between new and existing links, some abiguities my occur when it comes to characters that are
invalid in URLs. For example,
* [[say "NO" to #8]] should be rendered as "<a href="say_%22NO%22_to_%238">say "NO" to #8</a>" * [[100% match]] should be rendered as "<a
href="100%25_match>100% match</a>", URL-escaping the '%' * but what about a user pasting an existing link, "[[say_%22NO%22_to_%238]]"? We
shouldn't URL-escape the '%' or '#' here. * for links with explicit link text, we should definitiely not URL-escape the link:
"[[say_%22NO%22_to_%238|say "NO" to #8]]"
This is complicated by the fact that '#' can delimit the start of the anchor portion of a link.
* "[[Mambo #5]]" - URL-escape '#' => Mambo_%235 * "[[Mambo#origins]]" - do not URL-escape * "[[existing/link#Introduction|See the
Introduction]]" - definitely do not URL-escape
Since escaping is somewhat magic and therefore potentially counter-intuitive, we will: * only URL-escape '#' if it follows a whitespace
directly * always URL-escape '%' unless it is followed by two uppercase hex digits * always escape other characters that are invalid in
URLs
expand_wikilink <wikilink>
Replace "_" with spaces and unescape URL-encoded characters
find_links <content> <page>
Find wiki links in content.
Return a listref of linked (existing) and wanted pages.
SEE ALSO
MojoMojo, Module::Pluggable::Ordered
AUTHORS
Marcus Ramberg <mramberg@cpan.org>
LICENSE
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2010-05-23 MojoMojo::Formatter::Wiki(3pm)