- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- echo a string withou a new line
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2003 10:25 PM
тАО10-02-2003 10:25 PM
Please help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2003 10:30 PM
тАО10-02-2003 10:30 PM
Re: echo a string withou a new line
echo -n "hello" will not produce a newline but Berkley "echo" would be something like
echo "hello\c". I'd try the first one of these first.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2003 10:30 PM
тАО10-02-2003 10:30 PM
Re: echo a string withou a new line
echo xxx|tr "\n" " "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2003 10:31 PM
тАО10-02-2003 10:31 PM
Re: echo a string withou a new line
ie.
echo "blah blah\c"
Note the \c at the end.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2003 10:38 PM
тАО10-02-2003 10:38 PM
Re: echo a string withou a new line
echo "hello\c"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2003 10:42 PM
тАО10-02-2003 10:42 PM
Re: echo a string withou a new line
Just re-read your post with a little more detail and perhaps need to expand these answers a bit.
echo -n "some kind of string" >> file
Non-Berkley
echo "some kindof string\c" >> file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2003 10:43 PM
тАО10-02-2003 10:43 PM
Re: echo a string withou a new line
Another way is to use printf, using printf without any formatting arguments will do the job. Ex:
printf abcde
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2003 11:24 PM
тАО10-02-2003 11:24 PM
Re: echo a string withou a new line
when I was in a terminal, all your commands run correctely.
But to added the string at the end of a file (exactelly just after the last word of the last line), it dosen't work.
Please help me again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2003 11:36 PM
тАО10-02-2003 11:36 PM
Re: echo a string withou a new line
what was the command you used? If you open the file with xvi you can check if there is a "0a" char at the end or not. Is there?
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2003 12:05 AM
тАО10-03-2003 12:05 AM
SolutionIf you want to add the text to the end of a file as you describe, you are going to have to remove the newline from the end of the file first. In perl you might do
#!/usr/bin/perl
$DATA=`cat datafile`;
chop $DATA;
print "$DATA"."The string I want at the end\n";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2003 12:52 AM
тАО10-03-2003 12:52 AM
Re: echo a string withou a new line
#!/bin/sh
export STRING="abcde"
awk -v string=$STRING '
{ print $0;
}
END{ printf("%s",string);}' yourfile > out1
result in out1
Rgds,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2003 04:57 AM
тАО10-03-2003 04:57 AM
Re: echo a string withou a new line
If file is command-file of shell
echo "argument\c" print line without new-line character
echo "argument\n" new-line character
echo "argument\t" tab
echo "argument\r" carriage return.
if file is text-file and you edit it, (example with vi editor) you must to be in insert mode.
If lines added is in text-screen you must verifies setup of terminal in the options New-line and Wrap (check setting of tab also).
Bruno
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2003 05:42 AM
тАО10-03-2003 05:42 AM
Re: echo a string withou a new line
Here the solution with ksh:
#!/usr/bin/ksh
DATA=`cat /etc/PATH`
echo "$DATA""le_mot_a_ajouter\c" > /tmp/PATH.new
and with perl:
#!/usr/bin/perl
$DATA=`cat datafile`;
chop $DATA;
print "$DATA"."The string I want at the end\n";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2003 05:47 AM
тАО10-03-2003 05:47 AM
Re: echo a string withou a new line
I think I'm right in saying that there is a maximum string length in the shell (could be that I'm still living in the past on that though) so the shell solution here might not work for bigger files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2003 09:19 PM
тАО10-05-2003 09:19 PM
Re: echo a string withou a new line
I hope that your problem is solved... but i don't sure totally.
Good luck!
Bruno