Additional character output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Additional character output
# 1  
Old 06-13-2005
Additional character output

Hi there,

I am just wondering if somebody can help me find out why am I getting additional characters on my "echo" command to create a text file. Here's my unix script :

#!/bin/ksh
#============================================================
# Script Name : chk_ORDHD.ksh
# Description : This script checks for XORD* files with
# incorrect HD count value
#============================================================

. /glo71sw/pro4bin/crondevl716
DIRSCRIPT=$PRODATA/scripts
cd $PRODATA
XORDDOWNLD=`ls XORD????.DLD`
export XORDDOWNLD
echo $XORDDOWNLD >> jgo.log

# clear report files....
> check_ORDHD.incorrect
> check_ORDHD.correct

for i in $XORDDOWNLD
do

# after getting the file, make sure header count is correct.
TOT_CNT=`cat $i | wc -l`
TOT_HD=`cat $i | grep "HD" | cut -c17-25`
# Compare total lines with total count in HD record
if [ $TOT_CNT -eq $TOT_HD ]
then
echo "$i has correct count : $TOT_CNT" >> check_ORDHD.correct
else
echo "$i has incorrect count : HD = $TOT_HD, Record = $TOT_CNT" >> check_O
RDHD.incorrect
fi
done

if [ -s check_ORDHD.incorrect ]
then
cat check_ORDHD.incorrect | elm -s"ORD Files with incorrect HD" test@test.com
fi



And then when I run this, I get the following email output. I am not sure where the extra "U" and "B" are coming from :
XORD0001.DLD has incorrect count : HD = 000000005, Record = 61
XORD0002.DLD has incorrect count : HD = 000000040, Record = 43
XORD0003.DLD has incorrect count : HD = 000000028
U
U
B, Record = 139
XORD0004.DLD has incorrect count : HD = 000000100
U
U
B, Record = 213
XORD0005.DLD has incorrect count : HD = 000000033
U
U, Record = 108
XORD0007.DLD has incorrect count : HD = 000000008, Record = 57


Thanks!

Joseph
# 2  
Old 06-13-2005
My guess:

TOT_HD=`cat $i | grep "HD" | cut -c17-25`
is sometimes set to 4 lines worth of stuff. There are some "HD"'s that you were not expecting.

Try:
TOT_HD=`cat $i | grep "HD" | head -1 | cut -c17-25`
# 3  
Old 06-13-2005
Thank you very very very much! Smilie

You are right, there are other rows with "HD" record.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use awk to turn character to newline then scan output

i have a datafile (data.txt) that has the following data: #Beginner`echo... (4 Replies)
Discussion started by: SkySmart
4 Replies

2. UNIX for Beginners Questions & Answers

Separating output after final character

I'm trying to write a script that will email the contents of my Application folder to me. cd /Applications ListApps=$(ls) echo $ListApps | mail -s "Application Check" myself@myemail.com This sends it in a paragraphed block i.e: Adobe Acrobat Reader.app App Store.app Atom.app... (4 Replies)
Discussion started by: $shell_Learner
4 Replies

3. Shell Programming and Scripting

Help with if else with additional condition

Input file: 3420023_3422482,3422486_3423070 46910 1795263_1798343 32681 1837399_1838886 1534 2148674_2149696,2149698_2149772 10203 3825382_3825555,3827296_3827900 198 1839890_1840294 72 . . Output file 3420023_3422482,3422486_3423070 3420023_3422482,3422486_3423070 46910 1795263... (1 Reply)
Discussion started by: perl_beginner
1 Replies

4. UNIX for Dummies Questions & Answers

PS1 (Prompt character) appearing in cat output

RedHat Linux 5.8/Korn Shell I have text file name /etc/oracle/config.loc. It has the following text #Device/file getting replaced by device +OCR ocrconfig_loc=+DATA ocrmirrorconfig_loc=+OCRBut , when I open this file using cat , the PS1 character (for prompt) appears as the last character... (8 Replies)
Discussion started by: omega3
8 Replies

5. Shell Programming and Scripting

Oneliner ---split string to character by piping shell output to perl

Hello, I was trying to split a string to characters by perl oneliner. echo "The quick brown fox jumps over the lazy dog" | perl -e 'split // ' But did not work as with bash script pipe: echo "The quick brown fox jumps over the lazy dog" | fold -w1 | sort | uniq -ic 8 1 T 1... (6 Replies)
Discussion started by: yifangt
6 Replies

6. UNIX for Dummies Questions & Answers

Removing unnecessary eol ($) character from Oracle sql query output

Hi All, I am fetching oracle query result in shell variable. As columns numbers are more the output wraps in unix terminal .i.e one complete record in db gets store in multiple lines. with each line ends with $ character. I want to remove these unnecessary $ character but to keep required $... (8 Replies)
Discussion started by: Harshal22
8 Replies

7. Shell Programming and Scripting

Bad character in output file

Hi All, I am facing some problems with bad characters in my file.For example- 00000000509 TCI DEVOFFERS= 1 Now I want to remove all bad characters and replace with *. Please suggest some solution. Along with that How to mention a range of ASCII values in TR command to replace? ... (2 Replies)
Discussion started by: bghosh
2 Replies

8. UNIX for Dummies Questions & Answers

SED: Can't Repeat Search Character in SED Output

I'm not sure if the problem I'm seeing is an artifact of sed or simply a beginner's mistake. Here's the problem: I want to add a zero-width space following each underscore between XML tags. For example, if I had the following xml: <MY_BIG_TAG>This_is_a_test</MY_BIG_TAG> It should look like... (8 Replies)
Discussion started by: rhetoric101
8 Replies

9. Shell Programming and Scripting

Getting output on the behalf of a character

Hi all, I want to get show an entire line of a output on the behalf of a single character. Hope, its easy but not for me. I am giving an example of my task: -rw-r--r-- 1 dtiwari_x mkpasswd 0 Dec 30 19:02 =5 -rw-r--r-- 1 dtiwari_x mkpasswd 61952 Jan 7 18:32 Customizing the... (3 Replies)
Discussion started by: naw_deepak
3 Replies

10. UNIX for Advanced & Expert Users

sqlPlus output with new line character

Hi, I have a script which calls a sqlplus command and i'm saving the output in a variable. Z=`sqlplus -s $TC_ORACLE_USER/$TC_ORACLE_PASSWORD@$TC_CONNECT_STRING <<eof set echo off set head off set serveroutput on; set feedback off; select description from period where trunc(sysdate)... (2 Replies)
Discussion started by: decci_7
2 Replies
Login or Register to Ask a Question