Removing Space in File
I'm reading in a file with various table names, creating SQL to find a count of all the records in the table, then outputting both the table name and the record count to a file.
The output file has the table name, a space, then the record count.
I do not want that space there, but for the life of me, I can't figure out how to make it go away. I'd prefer to have a delimiter like a comma or anything else.
Here's my wee code to read the input file and create the output file (TableCount is another script that does the counting):
Perhaps the space that I see in the file, isn't really a space... what I've been doing is reading in that file, trying to strip out the space using sed, and writing it to another file just to see what I get. But sed doesn't want to strip out that space.
while read line
RECORDCOUNT=`TableCount $var1 $var2 $var3 $line`
echo "$line$RECORDCOUNT" >> $TABLECOUNTS
done < $TABLELIST
Seems simple... but I really am a scripting newbie, I don't know sed at all, so I'm going on examples I'm finding on the web. I keep getting a space between the table name and the record count.
while read line2
echo $line2 | sed 's/ */\|/g' >> $TABLECOUNTS2
done < $TABLECOUNTS
Can anyone help? When I load the output file into a Sybase table, and I do a select on it, I don't get the table name properly because it's putting the trailing space into the table. Or so it seems, anyway. I might see if I can just not take that space on the table load... but I wanted to try this first.
In the segment you posted here, it looks like there is no space, but some sort of newline instead.
Fortunately, it's relatively easy to find out what character you actually have there by using the "od" command. Try the -a and -c flags.