- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: query on vi (LINE FEED)
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
Forums
Discussions
Discussions
Discussions
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
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
06-18-2003 12:27 AM
06-18-2003 12:27 AM
I'm having trouble entering a 'LINE FEED' into a script:
OUTPUT="$FIRST $SECOND"
The application I'm sending the output to interprets 'LINE FEED' (0x0A, 10) as carriage return, however when I edit the script (vi, ctrl-V, ctrl-J as per 'man ascii') the '^J' is not displayed, instead:
OUTPUT="$FIRST
$SECOND"
'^M' is displayed correctly but does not produce the required output. Any ideas where I'm going wrong?
Many Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 12:32 AM
06-18-2003 12:32 AM
Re: query on vi (LINE FEED)
"vi" WILL show ^J as a new line. That's what it means.
What exactly are you trying to do with the output?
Ollie.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 01:13 AM
06-18-2003 01:13 AM
Re: query on vi (LINE FEED)
If you're writing a script, why don't you use symbolic forms ?
I'm not sure of what you want, but you could perhaps simply use :
OUTPUT="$FIRST\rSECOND" or OUTPUT="$FIRST\n$SECOND"
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 01:18 AM
06-18-2003 01:18 AM
Re: query on vi (LINE FEED)
It sounds like your application may be PC based, hence interprets the CR/LF differently from your HP-UX based script. You could use ux2dos to convert the output from LF to CR/LF which will then look correct in your application.
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 01:27 AM
06-18-2003 01:27 AM
Re: query on vi (LINE FEED)
Having looked at your original message again, I think I understand what you're trying to do.
Please could you try the following and see if this is what you're trying to achieve?
FIRST=first
SECOND=second
OUTPUT="$FIRST\012$SECOND"
echo $OUTPUT
Ollie.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 01:55 AM
06-18-2003 01:55 AM
Re: query on vi (LINE FEED)
What I need the script to forward to the application is HEX 0A, so:
OUTPUT="$FIRST<0A>$SECOND"
HEX 0A = LINE FEED = ^J
However, when I insert the ^J by doing the following, I do not receive 0A:
-vi file
-ctrl-V
-ctrl-J
Is it the editor? Entering '\n' '\r' won't work unfortunately.
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 02:00 AM
06-18-2003 02:00 AM
Re: query on vi (LINE FEED)
Try my previous reply - OCTAL 12 \012
Ollie.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 02:19 AM
06-18-2003 02:19 AM
Re: query on vi (LINE FEED)
No luck unfortunately, I see what you mean though. Is it possible to do something similar except specify 'HEX 10 (\?10)' instead of 'OCT 12 (\012)'?
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 02:23 AM
06-18-2003 02:23 AM
SolutionThose 2 numbers are equal, both represent ASCII value 10 (decimal), ie ^J.
Have you tried piping your script through od -tax; it'll show you the hex values and ascii characters that are being echoed?
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 02:25 AM
06-18-2003 02:25 AM
Re: query on vi (LINE FEED)
Why do you want to do HEX 10? That's a backspace!
If you want a newline (OCTAL 12) then the suggestion I give above will work.
What else are you trying to do?
Ollie.
(P.S. How about a bit of points assignment? I'm trying to get my cap today!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 02:26 AM
06-18-2003 02:26 AM
Re: query on vi (LINE FEED)
HEX 10 is "dle" (whatever that means).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 02:44 AM
06-18-2003 02:44 AM
Re: query on vi (LINE FEED)
why don't you try with redirection ?
your_command << EOF
$FIRST
$SECOND
EOF
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 02:54 AM
06-18-2003 02:54 AM
Re: query on vi (LINE FEED)
It's quite strange, because if you control the output using od it seems to work (either with \code or \n).
$ N="FIRST\nSECOND"
$ echo $N | od -cb
0000000 F I R S T \n S E C O N D \n
106 111 122 123 124 012 123 105 103 117 116 104 012
$ N="FIRST\012SECOND"
$ echo $N | od -cb
0000000 F I R S T \n S E C O N D \n
106 111 122 123 124 012 123 105 103 117 116 104 012
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 03:13 AM
06-18-2003 03:13 AM
Re: query on vi (LINE FEED)
My app wasn't padding out HEX fields with zero, so when the Line Feed was submitted it was passed along as 'A' instead of '0A' and messed everything else up!
Many thanks to all who replied.