Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Using read with escaped variables Post 302910293 by Corona688 on Wednesday 23rd of July 2014 12:30:07 PM
Old 07-23-2014
To tell read not to interpret backslashes, do read -r
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Read variables from Access table

Hi! I've just started learning shell scripting, and have been somewhat 'thrown in at the deep-end and told to swim' so excuse my complete lack of knowledge and ignorance, but here goes... I've been given a unix script to 'tidy up'. Basically the script consists of the few lines of code being... (2 Replies)
Discussion started by: Sn33R
2 Replies

2. Shell Programming and Scripting

How to read a line and put it into 3 variables

Hi All, I'll get a file whose 2nd line contains 3 fields: filename(variable length), file size char(10), and record count int(10). How do I cut it and put it into 3 variables? eg: abcd.csv01234567891111111111 now I want: $one = abcd.csv, $two = 0123456789, $three = 1111111111. I also... (8 Replies)
Discussion started by: Mandab
8 Replies

3. Shell Programming and Scripting

Cannot read variables after ssh with rc file (KSH)

Greetings all, I'm currently making use of the $HOME/.ssh/rc file to launch an automated shell script immediately after the user has been verified through ssh. The current problem that I'm facing now is that I am unable to use the "read" command anymore... seems like the "read" statements are... (0 Replies)
Discussion started by: rockysfr
0 Replies

4. Shell Programming and Scripting

read values from ps -ef into variables in ksh?

Hi, I want to get the first two items returned by ps -ef into two variables? Can anyone please help Thanks (8 Replies)
Discussion started by: JamesByars
8 Replies

5. Shell Programming and Scripting

Read variables from line to fixed length

I would like to make a script to read three variables (no fixed length or position) from a line and write them into a file, with fixed length and right-justified in each column. The fixed text (text1-text4) prior to the thee variables and the variables themselves are originally separated by spaces... (3 Replies)
Discussion started by: SharkM
3 Replies

6. Shell Programming and Scripting

while read loop; scope of variables (shell)

If I set a variable within a while-read loop, sometimes it's local to the loop, sometimes it's global, depending on how the loop is set up. I'm testing this on a Debian Lenny system using both bash and dash with the same results. For example: # Pipe command into while-read loop count= ls -1... (2 Replies)
Discussion started by: mjd_tech
2 Replies

7. Shell Programming and Scripting

how to write 2 variables while using read command

Hello All i have input files contains 2 values as following 20-Oct-09 Z59408009 20-Oct-09 Z59423060 and i am using the following script cat /home/or/input.txt | awk '{print $2}' >log count=0 while read line; do count=$(( count + 1 )) echo "UPDATE SAT_JRLTRT SET AVT='X' WHERE... (6 Replies)
Discussion started by: mogabr
6 Replies

8. Shell Programming and Scripting

Read variables and their values from file

Hi, I want to read the variables and the values from the txt file and compare these values with the ones computed by script. for ex: say var.txt contains the variable names and their values: one 1 two 2 three 3 The value of variables "one" "two" and "three" will be computed in the script... (3 Replies)
Discussion started by: bhushana
3 Replies

9. Shell Programming and Scripting

Read variables from a file and then export it.

Hi I want to read variables from one file and then set it as environment variable; The text file is test.txt which contains SPEED:1000 IP:172.26.126.11 My code is: while read line; do var1=`echo $line | awk 'BEGIN {FS=":"} { print $1 }'` echo $var1 var2=`echo $line | awk 'BEGIN {FS=":"}... (8 Replies)
Discussion started by: SSM
8 Replies

10. Shell Programming and Scripting

[BASH] Getting a semi-tailing backslash when passing (escaped) variables to script

Heyas Figured me had a 'typo' in tui-conf-set, i went to fix it. Now, i also figured, it might be nice to have tui-conf-set report (to console, not only exit code) wether it could save the variable to the file or not. This said, I appended this code: (the tui-title and tui-echo lines are... (3 Replies)
Discussion started by: sea
3 Replies
FPARSELN(3)						   BSD Library Functions Manual 					       FPARSELN(3)

NAME
fparseln -- return the next logical line from a stream LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> char * fparseln(FILE *stream, size_t *len, size_t *lineno, const char delim[3], int flags); DESCRIPTION
The fparseln() function returns a pointer to the next logical line from the stream referenced by stream. This string is NUL terminated and it is dynamically allocated on each invocation. It is the responsibility of the caller to free the pointer. By default, if a character is escaped, both it and the preceding escape character will be present in the returned string. Various flags alter this behaviour. The meaning of the arguments is as follows: stream The stream to read from. len If not NULL, the length of the string is stored in the memory location to which it points. lineno If not NULL, the value of the memory location to which is pointed to, is incremented by the number of lines actually read from the file. delim Contains the escape, continuation, and comment characters. If a character is NUL then processing for that character is disabled. If NULL, all characters default to values specified below. The contents of delim is as follows: delim[0] The escape character, which defaults to , is used to remove any special meaning from the next character. delim[1] The continuation character, which defaults to , is used to indicate that the next line should be concatenated with the current one if this character is the last character on the current line and is not escaped. delim[2] The comment character, which defaults to #, if not escaped indicates the beginning of a comment that extends until the end of the current line. flags If non-zero, alter the operation of fparseln(). The various flags, which may be or-ed together, are: FPARSELN_UNESCCOMM Remove escape preceding an escaped comment. FPARSELN_UNESCCONT Remove escape preceding an escaped continuation. FPARSELN_UNESCESC Remove escape preceding an escaped escape. FPARSELN_UNESCREST Remove escape preceding any other character. FPARSELN_UNESCALL All of the above. RETURN VALUES
Upon successful completion a pointer to the parsed line is returned; otherwise, NULL is returned. The fparseln() function uses internally fgetln(3), so all error conditions that apply to fgetln(3), apply to fparseln(). In addition fparseln() may set errno to [ENOMEM] and return NULL if it runs out of memory. SEE ALSO
fgetln(3) HISTORY
The fparseln() function first appeared in NetBSD 1.4. BSD
November 30, 2002 BSD
All times are GMT -4. The time now is 01:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy