You seem to have found the error in your first script - does the problem persist or is it solved? Please provide an indication of the status of the thread.
Thanks for you suggestion.
The problem was "^M" getting appended in the variable.
can you please let me know if i want to check the value if it has ^M, how to display then.
Thanks,
Vipin Kumar Rai
---------- Post updated at 08:30 AM ---------- Previous update was at 08:28 AM ----------
for eg.
abc="i am vipin^M"
cat $abc
it is not showing "^M" character but i want to show it.
what is the way?
cat prints input files (including stdin) to stdout. Use options like -A, -E, -T, -v to show control characters. echo or (preferrably) printf print text and/or variables to stdout; pipe this through e.g. cat -A to see if a ^M is there.
This said, we are off topic considering the thread's title and so I will close the thread.
Up the the user to open a new threadregarding his new request...
Yes - if the system uses GNU- cat (or some other non-standard-conforming variant). POSIX-cat has only one valid option: "-u" for unbuffered operation.
Three ways to avoid and/or manage "^M" characters:
First, DO NOT WRITE YOUR SCRIPTS IN WINDOWS AND THEN FTP THEM TO UNIX! This is how the overwhelming majority of misplaced ^M-characters come to pass.
Second, open the file in questsion in vi and then enter: ":set list". This will display non-printable characters: "^I" is a tab, "^M" is a (Windows-style) line feed, "$" is a newline character, etc.. use the command ":set nolist" to switch back to normal display.
Third, control your variable definitions:
var='foo
bar'
will place a "^M" character between "foo" and "bar".