Sponsored Content
Full Discussion: Read paragraph from file
Top Forums Shell Programming and Scripting Read paragraph from file Post 302949233 by neutronscott on Wednesday 8th of July 2015 10:56:23 AM
Old 07-08-2015
Don't use for to read lines. Use a while read loop.

This will loop over the file and grab the statement name from your ## lines. probably only good for single-line statements

Code:
#!/bin/bash

while read -r sql; do
  if [[ $sql = \#* ]]; then
    stmt=${sql#* }
  elif [[ $sql = *[![:space:]]* ]]; then  # has something besides blank
    if RunSQL "$sql"; then
      echo "$stmt:PASS"
    else
      echo "$stmt:FAIL"
    fi
  fi
done < "SQL.dat"


Last edited by neutronscott; 07-08-2015 at 12:06 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

selecting each paragraph and put it into a file...help me

Dear Friends, I need a shell script. I am facing a problem while selecting the text that is between start and end tags. and insert the paragraph into a file1, next paragraph in file2...... experts please help. i have a file which contains, -------------- <abc> 111some text some text some... (2 Replies)
Discussion started by: swamymns
2 Replies

2. Shell Programming and Scripting

Replacing a paragraph between pattern , with the content 4m another file

hi, i wanted to put the output of file f1 into the pattern space of file f2 f1: wjwjwjwjwjwjwj //these line go in file f2 jwjwjwjwjwjjwjw wjwjwjwjjwjwjwj f2: Pattern_start __________ //these are the line to be replaced __________ Pattern_end i m... (4 Replies)
Discussion started by: go4desperado
4 Replies

3. Programming

Cannot read a file with read(fd, buffer, buffersize) function

# include <stdio.h> # include <fcntl.h> # include <stdlib.h> # include <sys/stat.h> int main(int argc, char *argv) { int fRead, fPadded, padVal; int btRead; int BUFFSIZE = 512; char buff; if (argc != 4) { printf ("Please provide all of the... (3 Replies)
Discussion started by: naranja18she
3 Replies

4. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

5. Shell Programming and Scripting

Easy way to pull a paragraph from a text file?

I have a collection of text files that comprise a mailing list archive. I grep them to find an email that interests me, then open the file in a text editor to find the surrounding paragraph of text. Is there an easy way to do this from the shell instead? (2 Replies)
Discussion started by: CRGreathouse
2 Replies

6. UNIX for Dummies Questions & Answers

When reading a csv file, counter to read 20 lines and wait for minute then read next 20 till end

Hello All, i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file. Any inputs are appreciated ... (3 Replies)
Discussion started by: victor.s
3 Replies

7. Shell Programming and Scripting

Print each paragraph in a text file into excel file

Hi, I have a below text file, which needs to be printed into attached excel file. Please help me. Thanks (4 Replies)
Discussion started by: prash358
4 Replies

8. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

9. Shell Programming and Scripting

Retrieving a paragraph from a pdf file using shell commands

In the reference section of a research paper(in pdf form), many other paper names are cited which have been used inside the pdf at different places. If I give an input, the name of a paper which has been cited in the reference section and want to display the section (the paragraph) inside the pdf... (1 Reply)
Discussion started by: SK33
1 Replies

10. Shell Programming and Scripting

Join Lines every paragraph in a file.txt

Hi all, Is there any idea on how to automate convert the paragraph in one line in a file, this will happen after OCR the documents, OCR split every paragraph. I need to join all the paragraph in one line. #cat file.txtThe Commission on Higher Education (CHED) was created through Republic Act... (7 Replies)
Discussion started by: lxdorney
7 Replies
SQLSRV_FIELD_METADATA(3)												  SQLSRV_FIELD_METADATA(3)

sqlsrv_field_metadata - Retrieves metadata for the fields of a statement prepared bysqlsrv_prepare(3)orsqlsrv_query(3)

SYNOPSIS
mixed sqlsrv_field_metadata (resource $stmt) DESCRIPTION
Retrieves metadata for the fields of a statement prepared by sqlsrv_prepare(3) or sqlsrv_query(3). sqlsrv_field_metadata(3) can be called on a statement before or after statement execution. PARAMETERS
o $stmt - The statment resource for which metadata is returned. RETURN VALUES
Returns an array of arrays is returned on success. Otherwise, FALSE is returned. Each returned array is described by the following table: Array returned by sqlsrv_field_metadata +----------+---------------------------------------------------+ | Key | | | | | | | Description | | | | +----------+---------------------------------------------------+ | Name | | | | | | | The name of the field. | | | | | Type | | | | | | | The numeric value for the SQL type. | | | | | Size | | | | | | | The number of characters for fields of character | | | type, the number of bytes for fields of binary | | | type, or NULL for other types. | | | | |Precision | | | | | | | The precision for types of variable precision, | | | NULL for other types. | | | | | Scale | | | | | | | The scale for types of variable scale, NULL for | | | other types. | | | | |Nullable | | | | | | | An enumeration indicating whether the column is | | | nullable, not nullable, or if it is not known. | | | | +----------+---------------------------------------------------+ For more information, see sqlsrv_field_metadata in the Microsoft SQLSRV documentation. EXAMPLES
Example #1 sqlsrv_field_metadata(3) example <?php $serverName = "serverNamesqlexpress"; $connectionInfo = array( "Database"=>"AdventureWorks", "UID"=>"username", "PWD"=>"password"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn === false ) { die( print_r( sqlsrv_errors(), true)); } $sql = "SELECT * FROM Table_1"; $stmt = sqlsrv_prepare( $conn, $sql ); foreach( sqlsrv_field_metadata( $stmt ) as $fieldMetadata ) { foreach( $fieldMetadata as $name => $value) { echo "$name: $value<br />"; } echo "<br />"; } ?> SEE ALSO
sqlsrv_client_info(3). PHP Documentation Group SQLSRV_FIELD_METADATA(3)
All times are GMT -4. The time now is 02:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy