10-31-2008
Yeah, I'm also facing a similar sort of a situation.
Here is a demo line from my script:
var=$x"\n"$y
When i echo $var i am getting
Hello
There
But when I am passing this variable var as an argument to a Java program then it is receiving something like this
Hello\nThere
I tried replacing \n with System.getProperty("line.separator") but to no avail.
Thanks.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am trying to write a script to prepare some text for use as web content.
What is happening is that all the newlines in the textfile are ignored, so I want
to be able to replace/add a few characters so that for a file containg:
This is line 1.
This is line two.
This is line four.... (1 Reply)
Discussion started by: ghoti
1 Replies
2. Shell Programming and Scripting
Newline character "\n" not working for ksh in linux AS 3.0
Command :
$echo "Hi\nHi"
$Hi\nHi
$
Expected output :
$echo "Hi\nHi"
Hi
Hi
$
Can some help me on this
Thanks in advance
Sanish. (11 Replies)
Discussion started by: sanikv
11 Replies
3. Shell Programming and Scripting
Hi , i want to Concatenate a string and use the following code
str="i"
str="$str am \n"
str="$str a \n"
str="$str boy \n"
echo $str
I want to ouput this
i
am
a
boy
However it outputs
i am \n a \n boy \n (3 Replies)
Discussion started by: youareapkman
3 Replies
4. UNIX for Dummies Questions & Answers
hi,
I have a for loop where in I write some file name to another file.
I want to write all the filenames to another without any newlines. how can i avoid getting new lines with echo?
Thanks,
Srilaxmi (2 Replies)
Discussion started by: srilaxmi
2 Replies
5. Shell Programming and Scripting
Removed.
My question does not make sense. and SED does see the last newline character.
But I still have a question:
How to remove the last newline character(the newline character at the end of last line) using SED?
---------- Post updated 05-01-11 at 10:51 AM ---------- Previous update was... (7 Replies)
Discussion started by: kevintse
7 Replies
6. UNIX for Dummies Questions & Answers
variable="unix\nlinux"
echo $variable
expected output:
unix
linux
:wall: can i do that ??
thanks in advance!! (3 Replies)
Discussion started by: sathish92
3 Replies
7. Shell Programming and Scripting
hi i am having delimited .dat file having content like below.
test.dat(5 line of records)
======
PT2~Stag~Pt2 Stag Test.
Updated~PT2 S T~Area~~UNCEF R20~~2012-05-24 ~2014-05-24~~
PT2~Stag y~Pt2 Stag Test.
Updated~PT2 S T~Area~METR~~~2012-05-24~2014-05-24~~test
PT2~Pt2 Stag Test~~PT2 S... (4 Replies)
Discussion started by: sushine11
4 Replies
8. Shell Programming and Scripting
I have a file (pema)with a single long record which i have to break up into multiple lines
Input
s1aaaaaaaaaaaaaaaaaaaaaaas1bbbbbbbbbbs1cccccccccc
Output
s1aaaaaaaaaaaaaaaaaaaaaaa
s1bbbbbbbbbb
s1cccccccccc
m planning to do it by replacing s1 by \ns1 \n is the new line character
i... (5 Replies)
Discussion started by: pema.yozer
5 Replies
9. Shell Programming and Scripting
Hi all..
I have a text file which looks like below:
abcd
efgh
ijkl
(blank space)
I need to remove only the last (blank space) from the file. When I try wc -l the file name,the number of lines coming is 3 only, however blank space is there in the file.
I have tried options like... (14 Replies)
Discussion started by: Sathya83aa
14 Replies
10. Shell Programming and Scripting
I have a file which comes every day and the file data look's as below.
Vi abc.txt
a|b|c|d\n
a|g|h|j\n
Some times we receive the file with only a new line character in the file like
vi abc.txt
\n (8 Replies)
Discussion started by: rak Kundra
8 Replies
LEARN ABOUT OSX
log::message::item
Log::Message::Item(3pm) Perl Programmers Reference Guide Log::Message::Item(3pm)
NAME
Log::Message::Item - Message objects for Log::Message
SYNOPSIS
# Implicitly used by Log::Message to create Log::Message::Item objects
print "this is the message's id: ", $item->id;
print "this is the message stored: ", $item->message;
print "this is when it happened: ", $item->when;
print "the message was tagged: ", $item->tag;
print "this was the severity level: ", $item->level;
$item->remove; # delete the item from the stack it was on
# Besides these methods, you can also call the handlers on
# the object specifically.
# See the Log::Message::Handlers manpage for documentation on what
# handlers are available by default and how to add your own
DESCRIPTION
Log::Message::Item is a class that generates generic Log items. These items are stored on a Log::Message stack, so see the Log::Message
manpage about details how to retrieve them.
You should probably not create new items by yourself, but use the storing mechanism provided by Log::Message.
However, the accessors and handlers are of interest if you want to do fine tuning of how your messages are handled.
The accessors and methods are described below, the handlers are documented in the Log::Message::Handlers manpage.
Methods and Accessors
remove
Calling remove will remove the object from the stack it was on, so it will not show up any more in subsequent fetches of messages.
You can still call accessors and handlers on it however, to handle it as you will.
id
Returns the internal ID of the item. This may be useful for comparing since the ID is incremented each time a new item is created.
Therefore, an item with ID 4 must have been logged before an item with ID 9.
when
Returns the timestamp of when the message was logged
message
The actual message that was stored
level
The severity type of this message, as well as the name of the handler that was called upon storing it.
tag
Returns the identification tag that was put on the message.
shortmess
Returns the equivalent of a "Carp::shortmess" for this item. See the "Carp" manpage for details.
longmess
Returns the equivalent of a "Carp::longmess" for this item, which is essentially a stack trace. See the "Carp" manpage for details.
parent
Returns a reference to the Log::Message object that stored this item. This is useful if you want to have access to the full stack in a
handler.
SEE ALSO
Log::Message, Log::Message::Handlers, Log::Message::Config
AUTHOR
This module by Jos Boumans <kane@cpan.org>.
Acknowledgements
Thanks to Ann Barcomb for her suggestions.
COPYRIGHT
This module is copyright (c) 2002 Jos Boumans <kane@cpan.org>. All rights reserved.
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.
perl v5.16.2 2012-10-11 Log::Message::Item(3pm)