Sponsored Content
Top Forums Shell Programming and Scripting Read Embedded Newline characters with read (builtin) in KSH93 Post 302486891 by a_programmer on Monday 10th of January 2011 03:29:47 PM
Old 01-10-2011
Read Embedded Newline characters with read (builtin) in KSH93

Hi Guys,

Happy New Year to you all!

I have a requirement to read an embedded new-line using KSH's read builtin.
Here is what I am trying to do:

Code:
run_sql "select guestid, address, email from guest" | while read id addr email
do
   ## Biz logic goes here
done

I can take care of any embedded spaces by escaping them with a '\' in the run_sql utility and read would parse the value correctly.
However, address field can have embedded new line characters. Is there an escape sequence I can use to encode any embedded newlines, so the read command would store the new-line character in 'addr' variable?
I have tried '\n', but read doesn't recognize that escape-sequence.

Is there an option in read to accept embedded newlines? Or is there another builtin that can be used for this purpose?

Any help would be appreciated!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace characters then read the file without changing it

Hi All At the moment the following code works but ideally i do not want to have to change the original $1 tr "\r" "\n" < "$1" > "$1.fix" printf "\n" >> "$1.fix" mv "$1.fix" "$1" FILE=$1 coffee_out="splitmovie" coffee_fill="-splitAt" coffee_end="-self-contained -o output.mov $2"... (1 Reply)
Discussion started by: babajuma
1 Replies

2. Shell Programming and Scripting

Removing Embedded Newline from Delimited File

Hey there - a bit of background on what I'm trying to accomplish, first off. I am trying to load the data from a pipe delimited file into a database. The loading tool that I use cannot handle embedded newline characters within a field, so I need to scrub them out. Solutions that I have tried... (7 Replies)
Discussion started by: bbetteridge
7 Replies

3. Shell Programming and Scripting

Read text from a file between two characters..

I have a requirement where i have to read from a .sh file a text lying bet characters like 'SELECT' & ';'...Please help me out in this. I am new to shell scripting. (2 Replies)
Discussion started by: goutam_igate
2 Replies

4. UNIX for Dummies Questions & Answers

ksh93 newline character problem

Hi , I am working on Linux, with ksh93 installed. The following statement echo \\n just prints \n on this shell. However on pdksh echo \\n gives a blank new line as a output. What is the correct way of printing a new line character on the ksh93? (4 Replies)
Discussion started by: neeto
4 Replies

5. Programming

How to make gl_get_line read unicode characters

Hi, My program uses gl_get_line from libtecla to get user input from terminal. It works fine as long as I enter English at the terminal prompt. However, if I enter other languages, such as Chinese characters, either by typing in or cut-and-paste, the input characters get cleared from terminal... (5 Replies)
Discussion started by: tdw
5 Replies

6. Shell Programming and Scripting

how to read multi line characters in a single column

Hi, I have file in which fields are pipe (|) separated and the record separator is new line (\n). But sometime I am getting a field value which is spread across multiple line. Basically I am getting a file from another system in the below format and needs to process the file and load data into a... (3 Replies)
Discussion started by: satyaatcgi
3 Replies

7. Windows & DOS: Issues & Discussions

Read last 7 characters from line ?

I have a txt like this: 638.301 (0.00973985) @ 50+55 the thing I want to do is read the last seven characters from the end of the first line. how do I do this ? Thanks in advance and sorry for being DOS only here. (2 Replies)
Discussion started by: pasc
2 Replies

8. UNIX for Dummies Questions & Answers

Characters in a single read

Hi, I have the file which has the data : accctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaac cctaacccaaccctaaccctaaccctaaccctaaccctaaccctaacccc taaccctaaccctaaccctaaccctaacctaaccctaaccctaaccctaa ccctaaccctaaccctaaccctaaccctaacccctaaccctaaccctaaa... (24 Replies)
Discussion started by: rajivn786
24 Replies

9. Programming

How to read extended ASCII characters from stdin?

Hi, I want to read extended ASCII characters from keyboard using c language on unix/linux. How to read extended characters from keyboard or by copy-paste in terminal irrespective of locale set in the system. I want to read the input characters from keyboard, store it in an array or some local... (3 Replies)
Discussion started by: sanzee007
3 Replies

10. Programming

Read in numbers from console won't stop at newline.

Hello, I have snippet code from Lippman's <<C++ primer>>. The program is to convert regular decimal (0 ~ 15) numbers to basic hexdecimals. The instruction tells the program will execute by hitting newline at the end. When I tried to run the compiled program, hitting ENTER did not work as... (3 Replies)
Discussion started by: yifangt
3 Replies
tartdates(5)						      LinuxTaRT Special Dates						      tartdates(5)

NAME
tartdates - Special date configuration for LinuxTaRT DESCRIPTION
LinuxTaRT uses a configuration file called specialdates to enable the user to display a specific tagline on certain special dates. The name and location of this file is specified in the LinuxTaRT configuration file ~/.tartrc, but is usually: ~/.tartdates PARAMETERS
Each line of the special date file consists of a day of the year expressed as a two digit month, a forward-slash (/), a two digit date, a colon (:) and a line of text. mm/dd:tagline text Any line that does not conform to this specification will be treated as a comment. Comments may also be specified by prefixing text with a # symbol. Using this method, you can place a comment behind a date line. EXAMPLES
01/01:Happy New Year!! Will use "Happy New Year!!" as the tagline when the date is January 1st. 12/25:Merry Christmas to all! Displays "Merry Christmas to all!" as your tagline on Christmas day. FILES
~/.tartdates SEE ALSO
tart(1) tartrc(5) tart-custom(5) Mark Veinot 1.0.0 tartdates(5)
All times are GMT -4. The time now is 08:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy