|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.csvLast edited by Scrutinizer; 12-27-2012 at 07:19 AM.. Reason: code tags; anonimized email addresses |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
file is Code:
Hi How Are You. Awk command : Code:
#awk '{ printf "%s ", $0 }' fileResult : Code:
Hi How Are You. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
are you looking out for something like this ? Code:
[root@testbox tmp]# cat file Hi How Are You. [root@testbox tmp]# tr -s '\n' ' ' < file Hi How Are You. |
|
#4
|
||||
|
||||
|
Problem with solution in post #2 and #3 is that it does not stop.
If there are more words following, it will be printed on the same line. So you need some type of record separator. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
try also: Code:
awk '$1=$1' RS= infile |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| remove ] followed by newline in bash | locoroco | Shell Programming and Scripting | 4 | 12-15-2011 12:44 PM |
| Create an .csv/excel file using shellscript | Navya | Shell Programming and Scripting | 12 | 07-15-2011 10:45 AM |
| remove newline between two string with sed command in unix shellscript | jcrshankar | Shell Programming and Scripting | 4 | 02-21-2011 05:46 PM |
| SED: how to remove newline after pattern? | nico.ben | Shell Programming and Scripting | 1 | 01-02-2009 09:59 PM |
| how to remove all tabs and newline (\n) | pvr_satya | Shell Programming and Scripting | 2 | 08-16-2008 02:38 PM |
|
|