Need to avoid empty line error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to avoid empty line error
# 1  
Old 07-26-2010
Need to avoid empty line error

Hi,
Below shell script executes based on liasted data files parameters.But small problem need to avoid ,If any empty line occures in dat files it's throwing oracle error .Need to ignore empty lines (means does not ready by script).Please advice.

Code:
 
#/bin/sh
adsts=`cat /tmp/flow_files/settings.dat | awk -F"," '{printf "EXEC CIM_MGMT_INSTALL1.addSetting(%c%s%c%c%c%s%c%c%c%s%c%c%s)\n",39,"Settings",39,44,39,"Settings",39,44,39,$1,39,44,1}'`
adflow=`cat /tmp/flow_files/flow.dat | awk -F"," '{printf "EXEC CIM_MGMT_INSTALL1.addFlow(%c%s%c%c%c%.1f%c%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%s)\n",39,$1,39,44,39,$2,39,44,39,$3,39,
44,39,"Settings",39,44,39,$4,39,44,39,$5,39,44,39,$6,39,44,$7}'`
addgp=`cat /tmp/flow_files/flow_group.dat | awk -F"," '{printf "EXEC CIM_MGMT_INSTALL1.addGroup(%c%s%c%c%c%s%c%c%s)\n",39,$1,39,44,39,$2,39,44,1}'`
adgpm=`cat /tmp/flow_files/flow_groupmap.dat | awk -F"," '{printf "EXEC CIM_MGMT_INSTALL1.addGroupMap(%s%c%c%s%c%c%c%s%c%c%s)\n",$1,44,39,$2,39,44,39,$3,39,44,1}'`
adsch=`cat addschedule.dat | nawk -F"," '{printf "EXEC CIM_MGMT_INSTALL1.addSchedule(%c%s%c%c%c%s%c%c%s%c%c%s%c%c%s%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%s%c%c%
s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c%c%c%s%c)\n",39,$1,39,44,39,$2,39,44,$3,44,39,$4,39,44,$5,44,39,$6,39,44,39,$7,39,44,39,$8,39,44,39,$9,39,44,39,$10,39,44,39,$11,39,44,39,$12,39,
44,39,$13,39,44,$14,44,39,$15,39,44,39,$16,39,44,39,$17,39,44,39,$18,39,44,39,$19,39,44,39,$20,39,44,39,$21,39}'`
result=`su - oracle -c "sqlplus oam/oam <<EOF
show user
$adsts
$adflow
$addgp
$adgpm
$adsch
EOF
" | egrep "successfully|ORA" | tr "\n" " " `
count=`echo $result | grep -i ora | wc -l`
 if [ $count -eq 1 ]; then
 echo $result
echo $count
  fi


Last edited by Scott; 07-26-2010 at 02:47 AM.. Reason: Code tags
# 2  
Old 07-26-2010
Following code will ignore any empty lines
Code:
grep -v ^$

# 3  
Old 07-26-2010
Thanks you hari
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Avoid printing entire line if string not found

so im searching the process table with: ps -ef | awk -F"./rello.java" '{ print substr($0, index($0,$2)) }' I only want it to print everything that's infront of the "./rello.java". That's because im basically getting the arguments that was passed to the rello.java script. this works. ... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

3. Shell Programming and Scripting

Avoid single line output from function

I am new to shell scripting and wished to get few things clarified. While calling functions within shell script, output comes out as single line irrespective of the no of echos or newlines I tried within function + the echo -e used to invoke function ( as instructed online) : #!/bin/sh inc() {... (1 Reply)
Discussion started by: RMath
1 Replies

4. Programming

[SOLVED] C++ print next line until line.empty

Hi, could you please help with the following: I have an input file like: one two three four five six I want to print the lines starting from 'three' to the empty line. Something like that: if ( line == "three" ) { while ( !line.empty() ) { cout <<... (0 Replies)
Discussion started by: apenkov
0 Replies

5. Shell Programming and Scripting

I need to know how to replace a line after a pattern match with an empty line using SED

Hi How Are you? I am doing fine! I need to go now? I will see you tomorrow! Basically I need to replace the entire line containing "doing" with a blank line: I need to the following output: Hi How Are you? I need to go now? I will see you tomorrow! Thanks in advance.... (1 Reply)
Discussion started by: sags007_99
1 Replies

6. Shell Programming and Scripting

How to avoid new line

Hi, I am having multiple echo statements to print output echo "$VAr" echo "$lenght" echo "$sum" I get the output as 12 24 36 I need the output to be 12 24 36. How do i arrive at this. Thanks in advance (4 Replies)
Discussion started by: krashraj
4 Replies

7. Shell Programming and Scripting

Plz Help-how to avoid blank next line

Hi, I want to pick the latest file name and save it in a file. later i'll be insert this file name in a oracle table.But i m getting a strange issue. while putting the file name to a file, some extra blank line also coming to that file.i m using cmd.... ls -t *_xxx_*.dat head - 1 > yyy.csv In... (5 Replies)
Discussion started by: palash
5 Replies

8. Shell Programming and Scripting

Fill the empty line by adding line before blank line

FIle A "A" 2 aa 34 3 ac 5 cd "B" 3 hu 67 4 fg 5 gy output shud be A"" 2 aa 34 "A" 3 ac 34 "A" 5 cd 34 "B" 3 hu 67 "B" 4 fg 67 "B" 5 gy 67 (6 Replies)
Discussion started by: cdfd123
6 Replies

9. Shell Programming and Scripting

howto add line as a first line into a non empty file

Hi Trying to do like this : echo "$variable1\n $(cat file.txt)" but it only adds one time. When I run this cmd again with different variable it only replaces line of variable1. How to add constantly line into first line in file ? (3 Replies)
Discussion started by: presul
3 Replies

10. Shell Programming and Scripting

how to avoid new line characters

Hi, I am using gzip command to compress the files at the UNIX server and FTP ing it in Binary mode to Windows server.(If ASCII mode is used im getting the output as junk characters) When i extract the files at Windows server a new line character is getting appended to the output file which is not... (4 Replies)
Discussion started by: Codesearcher
4 Replies
Login or Register to Ask a Question