Sponsored Content
Top Forums Shell Programming and Scripting ShellScript to Remove Newline in ouput.csv Post 302748955 by crmsachin on Thursday 27th of December 2012 07:08:07 AM
Old 12-27-2012
ShellScript to Remove Newline in ouput.csv

Hi friends,
I am running one SQL though .sh file and in output I am seeing newline whevnever There is a new line in column.
I WANT TO REMOVE NEWLINE IN OUTPUT FILE.

Present out put in Column:
-------------------------
Code:
Hi
How 
Are 
You.

Required output in Column:
-------------
Code:
Hi How Are You.

Can anybody help me how to resolve this in Shell Script?? Below is my Script:

Code:
ORACLE_HOME=/app/oracle/product/11.1.0/client_1 ; export ORACLE_HOME
PATH=$PATH:/app/oracle/product/11.1.0/client_1/bin ; export PATH
cd /crmapp/crmpm

m=`date +%Y%m%d`

sqlplus -s abcd/efgh@crmdb << EOF

set echo off
set newpage 0
set space 0
set pagesize 0
set linesize 20000
set feed off
set heading on
set trimspool on


spool Direct_Debit_Report_$m.csv

select 'SR_Number'||','||'BANNumber'||','||'Name'||','||'CPR#'||','||'DD_Ref_Num'||','||'MSISDN'||','||'BankName'||','||'Bank_Account_Name'||','||'AccountNumber'||','||'DD_Max_Amount'||','||'DD_Max_Amount_Amend'||','||'DD_StartDate'||','||'SR_Tier-3'||','||'SR_Created'||','||'SR_Status'||','||'SR_SubStatus'||','||'Description' from dual;

select sr.sr_num||','||b.ou_num||','||b.name||','||can.tax_iden_num||','||sr.X_DD_REF_NUM||','||a.duns_num||','||x.X_BANK_NAME||','||x.X_BANK_ACC_NAME||','||x.X_BANK_ACCOUNT_NUM||','||sr.X_DD_MAX_AMT||','||sr.X_DD_MAX_AMT_AMEND||','||sr.X_DD_START_DATE||','||sr.SR_SUB_AREA||','||SR.CREATED||','||sr.SR_STAT_ID||','||sr.sr_sub_stat_id||','||sr.desc_text
from siebel.s_org_ext a,siebel.s_org_ext b,siebel.s_srv_req sr,siebel.s_srv_req_x x,siebel.s_org_ext can 
where a.ROW_ID = SR.CST_OU_ID AND
a.master_ou_id = can.row_id and
sr.row_id = x.par_row_id and
a.par_ou_id = b.row_id and
sr.sr_sub_area in ('Amendment','Cancellation','New') and
trunc(sr.created) >= (sysdate-7);

spool off
quit
EOF

#mailx -m -s "Direct Debit Report" xxx@viva.com.bh,yyy@viva.com.bh,aimakki.c@viva.com.bh,zzz@viva.com.bh  << EOF
#mailx -m -s "Direct Debit Report $m" aaa@viva.com.bh << EOF
mailx -m -s "Direct Debit Report" aaa@viva.com.bh << EOF



Hi,

PFA Direct Debit SR's since yesterday.

Note: If the sheet is blank it indicates that there is no DD SR raised since yesterday.


Thanks & Regards,
CRM Team

$(/usr/bin/uuencode "/crmapp/crmpm/Direct_Debit_Report_$m.csv" Direct_Debit_Report_$m.csv)

EOF

rm /crmapp/crmpm/Direct_Debit_Report_$m.csv


Last edited by Scrutinizer; 12-27-2012 at 08:19 AM.. Reason: code tags; anonimized email addresses
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to remove all tabs and newline (\n)

how to remove all tabs and newline (\n) from the exicting file (2 Replies)
Discussion started by: pvr_satya
2 Replies

2. Shell Programming and Scripting

Remove newline character conditionally

Hi All, I have 5000 records like this Request_id|Type|Status|Priority|Ticket Submitted Date and Time|Actual Resolved Date and Time|Current Ticket Owner Group|Case final Ticket Owner Group|Customer Severity|Reported Symptom/Request|Component|Hot Topic|Reason for Missed SLA|Current Ticket... (2 Replies)
Discussion started by: j_53933
2 Replies

3. Shell Programming and Scripting

sed/awk remove newline

Hi, I have input file contains sql queries i need to eliminate newlines from it. when i open it vi text editor and runs :%s/'\n/'/g it provides required result. but when i run sed command from shell prompt it doesn't impact outfile is still same as inputfile. shell] sed -e... (6 Replies)
Discussion started by: mirfan
6 Replies

4. Shell Programming and Scripting

remove newline between two string with sed command in unix shellscript

I have a file (test.dat) which contains data like this 459|199811047|a |b |shan kar|ooty| 460|199811047|a |bv |gur u|cbe| but I need it like: 459|199811047|a |b |shankar|ooty| 460|199811047|a |b |guru|cbe| While reading the data from this file, I don't want to remove newline from the end of... (4 Replies)
Discussion started by: jcrshankar
4 Replies

5. Shell Programming and Scripting

Create an .csv/excel file using shellscript

In my file, i have 4 Product names(For ex:Microsoft excel, Oracle,.Net,IBM websphere,..etc.,) I want this 4 Products in 4 individual .csv/excel file after running the script with those products related information. (12 Replies)
Discussion started by: Navya
12 Replies

6. Shell Programming and Scripting

remove ] followed by newline in bash

I need to remove ] followed by newline character to convert lines like: line1] line2 into: line1line2 (4 Replies)
Discussion started by: locoroco
4 Replies

7. Shell Programming and Scripting

Remove newline character between two delimiters

hi i am having delimited .dat file having content like below. test.dat(5 line of records) ====== PT2~Stag~Pt2 Stag Test. Updated~PT2 S T~Area~~UNCEF R20~~2012-05-24 ~2014-05-24~~ PT2~Stag y~Pt2 Stag Test. Updated~PT2 S T~Area~METR~~~2012-05-24~2014-05-24~~test PT2~Pt2 Stag Test~~PT2 S... (4 Replies)
Discussion started by: sushine11
4 Replies

8. Linux

Remove newline in middle of string

my file input is with tab as delimiter, and in every line, there would be a skip of line with an unexcepted newline breaker. I'd like to remove this \n and put the information in the same line. INPUT a1 b1b2 c1 c2 d1 a2 b3 c3 d4 OUTPUT a1 b1b2 c1c2 ... (9 Replies)
Discussion started by: kinkichin
9 Replies

9. Shell Programming and Scripting

Remove last newline character..

Hi all.. I have a text file which looks like below: abcd efgh ijkl (blank space) I need to remove only the last (blank space) from the file. When I try wc -l the file name,the number of lines coming is 3 only, however blank space is there in the file. I have tried options like... (14 Replies)
Discussion started by: Sathya83aa
14 Replies

10. Shell Programming and Scripting

Shellscript command to remove files starting with a certain string, and older than 3 days

Hi All, Need help in identifying a shellscript command to remove all files on a server directory, starting with a certain prefix and also older than 3 days. That means files created with that prefix, today or yesterday, shouldn't be removed. Thanks, Dev (3 Replies)
Discussion started by: dev.devil.1983
3 Replies
SQLITE3(1)						      General Commands Manual							SQLITE3(1)

NAME
sqlite3 - A command line interface for SQLite version 3 SYNOPSIS
sqlite3 [options] [databasefile] [SQL] SUMMARY
sqlite3 is a terminal-based front-end to the SQLite library that can evaluate queries interactively and display the results in multiple formats. sqlite3 can also be used within shell scripts and other applications to provide batch processing features. DESCRIPTION
To start a sqlite3 interactive session, invoke the sqlite3 command and optionally provide the name of a database file. If the database file does not exist, it will be created. If the database file does exist, it will be opened. For example, to create a new database file named "mydata.db", create a table named "memos" and insert a couple of records into that table: $ sqlite3 mydata.db SQLite version 3.1.3 Enter ".help" for instructions sqlite> create table memos(text, priority INTEGER); sqlite> insert into memos values('deliver project description', 10); sqlite> insert into memos values('lunch with Christine', 100); sqlite> select * from memos; deliver project description|10 lunch with Christine|100 sqlite> If no database name is supplied, the ATTACH sql command can be used to attach to existing or create new database files. ATTACH can also be used to attach to multiple databases within the same interactive session. This is useful for migrating data between databases, possibly changing the schema along the way. Optionally, a SQL statement or set of SQL statements can be supplied as a single argument. Multiple statements should be separated by semi-colons. For example: $ sqlite3 -line mydata.db 'select * from memos where priority > 20;' text = lunch with Christine priority = 100 SQLITE META-COMMANDS The interactive interpreter offers a set of meta-commands that can be used to control the output format, examine the currently attached database files, or perform administrative operations upon the attached databases (such as rebuilding indices). Meta-commands are always prefixed with a dot (.). A list of available meta-commands can be viewed at any time by issuing the '.help' command. For example: sqlite> .help .databases List names and files of attached databases .dump ?TABLE? ... Dump the database in an SQL text format .echo ON|OFF Turn command echo on or off .exit Exit this program .explain ON|OFF Turn output mode suitable for EXPLAIN on or off. .header(s) ON|OFF Turn display of headers on or off .help Show this message .import FILE TABLE Import data from FILE into TABLE .indices TABLE Show names of all indices on TABLE .mode MODE ?TABLE? Set output mode where MODE is one of: csv Comma-separated values column Left-aligned columns. (See .width) html HTML <table> code insert SQL insert statements for TABLE line One value per line list Values delimited by .separator string tabs Tab-separated values tcl TCL list elements .nullvalue STRING Print STRING in place of NULL values .output FILENAME Send output to FILENAME .output stdout Send output to the screen .prompt MAIN CONTINUE Replace the standard prompts .quit Exit this program .read FILENAME Execute SQL in FILENAME .schema ?TABLE? Show the CREATE statements .separator STRING Change separator used by output mode and .import .show Show the current values for various settings .tables ?PATTERN? List names of tables matching a LIKE pattern .timeout MS Try opening locked tables for MS milliseconds .width NUM NUM ... Set column widths for "column" mode sqlite> OPTIONS
sqlite3 has the following options: -init file Read and execute commands from file , which can contain a mix of SQL statements and meta-commands. -echo Print commands before execution. -[no]header Turn headers on or off. -bail Stop after hitting an error. -interactive Force interactive I/O. -batch Force batch I/O. -column Query results will be displayed in a table like form, using whitespace characters to separate the columns and align the output. -cmd command Run command before reading stdin. -csv Set output mode to CSV (comma separated values). -html Query results will be output as simple HTML tables. -line Query results will be displayed with one value per line, rows separated by a blank line. Designed to be easily parsed by scripts or other programs -list Query results will be displayed with the separator (|, by default) character between each field value. The default. -separator separator Set output field separator. Default is '|'. -nullvalue string Set string used to represent NULL values. Default is '' (empty string). -stats Print memory stats before each finalize. -version Show SQLite version. -vfs name Use name as the default VFS. -help Show help on options and exit. INIT FILE
sqlite3 reads an initialization file to set the configuration of the interactive environment. Throughout initialization, any previously specified setting can be overridden. The sequence of initialization is as follows: o The default configuration is established as follows: mode = LIST separator = "|" main prompt = "sqlite> " continue prompt = " ...> " o If the file ~/.sqliterc exists, it is processed first. can be found in the user's home directory, it is read and processed. It should generally only contain meta-commands. o If the -init option is present, the specified file is processed. o All other command line options are processed. SEE ALSO
http://www.sqlite.org/ The sqlite-doc package AUTHOR
This manual page was originally written by Andreas Rottmann <rotty@debian.org>, for the Debian GNU/Linux system (but may be used by oth- ers). It was subsequently revised by Bill Bumgarner <bbum@mac.com>. Mon Apr 15 23:49:17 2002 SQLITE3(1)
All times are GMT -4. The time now is 12:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy