Sponsored Content
Top Forums Shell Programming and Scripting While read line ignores the '\' in file content Post 302569381 by Prev on Monday 31st of October 2011 05:35:58 AM
Old 10-31-2011
While read line ignores the '\' in file content

I need to read temp.$i file content line by line through while loop but somehow the '\' do not appear in output.. Can someone guide how to read this exact content line by line in unix :
Code:
        if [ -s "temp.$i" ]
        then
           cat temp.$i | head -1 # the file content appears fine 
           while read line1
           do
                 echo "$line1"   # the '\''s are being ignored in output
                 exit
          done < temp.$i
        fi

Output:
Code:
AM_DASHBOARD\MAIN\02RUN\RUNMISURE_E2E, sequence job  # ok
AM_DASHBOARDMAIN02RUNRUNMISURE_E2E, sequence job      #not ok

--------------------------------------

Last edited by Scott; 10-31-2011 at 07:20 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read the content of the particular file from tar.Z without extracting?

Hi All, I want to read the content of the particular file from tar.Z without extracting. aaa.tar.Z contains a file called one.txt, I want to read the content of the one.txt without extracting. Please help me to read the content of it. Regards, Kalai. (12 Replies)
Discussion started by: kalpeer
12 Replies

2. Shell Programming and Scripting

read a file and use the content for mapping

help me pls.. :( i want to read a mapping file. Below is the content of my mapping file. 6221,189,SMSC1,OMC1,WAP1 6223,188,SMSC2,OMC2,WAP2 so when my program running msisdn="622130302310" while not EOF if substring($msisdn,1,4) == "6221" -- > "6221" read from the file then echo... (0 Replies)
Discussion started by: voidmain
0 Replies

3. Shell Programming and Scripting

Read a file content with awk and sed

Hello , I have huge file with below content. I need to read the numeric values with in the paranthesis after = sign. Please help me with awk and sed script for it. 11.10.2009 04:02:47 Customer login not found: identifier=(0748502889) prefix=(TEL) serviceCode=(). 11.10.2009 04:03:12... (13 Replies)
Discussion started by: rmv
13 Replies

4. Shell Programming and Scripting

read file content

i have one file abhi.txt its contents are home8/mc09ats/UnixCw/backup/file1 home8/mc09ats/file2 i want to read this content of file using while loop.. in this i want to seperate the content as follows path=home8/mc09ats/UnixCw/backup file=file1 echo path echo file can you... (1 Reply)
Discussion started by: AbhijitIT
1 Replies

5. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

6. Shell Programming and Scripting

How to read file and only output certain content

Hi - I have a file containing data like :- cn=tommy,cn=users,c=uk passwordexpirydate=20100530130623z cn=jane,cn=users,c=uk passwordexpirydate=20100423140734z cn=michael,cn=users,c=uk passwordexpirydate=20100331020044z I want to end up with a file that looks like:-... (6 Replies)
Discussion started by: sniper57
6 Replies

7. Shell Programming and Scripting

Read a text file and print the content..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... ... (7 Replies)
Discussion started by: samupnl
7 Replies

8. Shell Programming and Scripting

cut the variable from the line and use it to find the file and read the content of that file

Hi, I am working on one script..I am having files in the below format file 1 (each line is separated with : delimeter) SPLASH:SPLASH:SVN CIB/MCH:MCH:SVN Now I want from file 1 that most left part of the first line will store in... (6 Replies)
Discussion started by: rohit22hamirpur
6 Replies

9. How to Post in the The UNIX and Linux Forums

GREP function in ksh which ignores LINE Breaks

I am using a grep command with two patterns in my KSH script. File has line breaks in it and both the patterns are in different lines. Here is the command - grep -l 'RITE AID.*ST.820' natriter820u.20140914 Pattern1 - RITE AID Pattern2 - ST*820 I am not getting any results from this,... (3 Replies)
Discussion started by: Raghav Garg
3 Replies

10. UNIX for Dummies Questions & Answers

GREP function in ksh which ignores LINE Breaks

Hello I am using a grep command with two patterns in my KSH script. File has line breaks in it and both the patterns are in different lines. Here is the command grep -l 'RITE AID.*ST.820' natriter820u.20140914 Pattern1 - RITE AID Pattern2 - ST*820 I am not getting any results from... (24 Replies)
Discussion started by: Raghav Garg
24 Replies
Ns_ConnRead(3aolserver) 				   AOLserver Library Procedures 				   Ns_ConnRead(3aolserver)

__________________________________________________________________________________________________________________________________________________

NAME
Ns_ConnGets, Ns_ConnRead, Ns_ConnFlushHeaders, Ns_ConnReadHeaders, Ns_ConnReadLine - Routines to copy connection content SYNOPSIS
#include "ns.h" char * Ns_ConnGets(buf, bufsize, conn) int Ns_ConnFlushContent(conn) int Ns_ConnRead(conn, vbuf, toread) int Ns_ConnReadHeaders(conn, set, nreadPtr) int Ns_ConnReadLine(conn, dsPtr, nreadPtr) ARGUMENTS
char *buf (in) Pointer to string buffer of length bufsize. int bufsize (in) Length of buffer pointer to by buf. Ns_Conn conn (in) Pointer to open connection. Ns_DString dsPtr (out) Pointer to initialized dstring to receive copied line. int *nreadPtr(out) Pointer to integer to receive number of bytes copied. Ns_Set set (in/out) Pointer to initialized Ns_Set to copy headers. int toread (in) Number of bytes to copy to location starting at vbuf void *vbuf (in) Pointer to memory location to copy content. _________________________________________________________________ DESCRIPTION
These routines support copying content from the connection. They all operate by copying from the content buffer returned by a call to Ns_ConnContent, maintaining a private, shared offset into the content. This means that these routines are not actually reading directly from the network and thus will not block waiting for input. See the man page on Ns_ConnContent for details on how the content is pre-read by the server and how resources are managed for small and large content requests. char *Ns_ConnGets(buf, bufsize, conn) Copies the next available line of text from the content to the given buf string, up to the given bufsize less space for a trailing null (). The result is a pointer to buf or NULL if an underlying call to Ns_ConnRead fails. int Ns_ConnFlushContent(conn) Performs a logical flush of the underlying content available to these routines. It simply moves the private offset to the end of the content. The result is NS_OK unless an underlying call to Ns_ConnContent failed in which case NS_ERROR is returned. int Ns_ConnRead(conn, vbuf, toread) Copies up to toread bytes from the content to the memory location pointed to by vbuf. The result is the number of bytes copied which will match toread unless less bytes are available in the input or -1 if an underlying call to Ns_ConnContent failed. int Ns_ConnReadHeaders(conn, set, nreadPtr) Copies lines up to the first blank line or end of content up to the maximum header read size specified with the communication driver "maxheader" parameter (default: 32k). Each line is parsed into "key: value" pairs into the given Ns_Set pointed to be the set argu- ment using the Ns_ParseHeader routine with the Ns_HeaderCaseDisposition specified by the "headercase" server option (default: Pre- serve). The result is NS_OK if all lines were consumed or NS_ERROR on overflow beyond the max header limit or if there was an error with the underlying call to Ns_ConnRead (including an error of a single line beyond the max line limit as described below). The integer pointed to by the nreadPtr argument, if given, is updated with the total number of bytes consumed. This routine can be use- ful when parsing multipart/form-data content to collect headers for each part. int Ns_ConnReadLine(conn, dsPtr, nreadPtr) Copies the next available line to the given dsPtr dstring. The integer pointed to by nreadPtr, if present, is updated with the num- ber of bytes copied. The line will not include the trailing or if present. The function will return NS_OK unless an under- lying call to Ns_ConnContent failed or the line exceeds the maximum line read size specified by the communication driver "maxline" parameter (default: 4k). This routine differs from Ns_ConnGets in that it copies the result to a dstring instead of a character buffer, requires a full or end-of-content terminated line, and enforces the maxline limit. SEE ALSO
Ns_ConnContent(3), Ns_ParseHeader(3) KEYWORDS
connection, read, content AOLserver 4.0 Ns_ConnRead(3aolserver)
All times are GMT -4. The time now is 05:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy